Help with setting proxy_header

Francis Daly francis at
Sat Mar 24 19:58:15 UTC 2012

On Sat, Mar 24, 2012 at 12:40:06AM +0000, Micheal Wolfskill wrote:

Hi there,

>              if ($host = '' ) { proxy_set_header Host; }
>                 location / { proxy_pass;  }

You want to have

  proxy_set_header Host $host;

unless $host is this IP address, in which case you want a different value?

  set $myhost $host;
  if ($host = '') { set $myhost; }
  proxy_set_header Host $myhost;

where the first two are at server{} level, and the last is at server{}
or location{} level.

Using the "map" directive is another way of setting your $myhost variable.

Francis Daly        francis at

More information about the nginx mailing list