Welcome! Log In Create A New Profile

Advanced

Re: Help with setting proxy_header

Alexander Kolesen
March 26, 2012 07:22AM
> Hello!
>
> I have a reverse proxy setup like this...
>
> server {
> ......
> ......
>
> if ($host = '23.71.33.142' ) { proxy_set_header Host
> www.domain.com; }
> location / { proxy_pass http://31.186.1.131:60/; }
>
> }
>
> The problem is that i cannot have a proxy_set_header inside an IF like this.
> Basically what iam intending to do is.. If the remote client visits my server
> with the IP (23.71.33.142) as the header (by using http://23.71.33.142) I need
> to send hardcoded the header to the backend server si my backend server knows
> it should respond with the content of domain.com . If they send any other
> header then it needs to be past to the backend server to deal with intact (it
> can be domain.com / www.domain.com / sub.domain.com )
>
> Thanks!
>
> --Mike
>

The more proper way is to use 'map' directive:

map $remote_addr $myhost {
default $http_host;
23.71.33.142 www.domain.com;
}

server {
....
location / {
proxy_set_header Host $myhost;
}
....
}

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Help with setting proxy_header

Micheal Wolfskill March 23, 2012 08:42PM

Re: Help with setting proxy_header

Francis Daly March 24, 2012 04:00PM

Re: Help with setting proxy_header

Alexander Kolesen March 26, 2012 07:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 263
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready