0

I tried to change the value of the $host variable to $http_x-real-host:

set $host $http_x-real-host;

In response, I receive a message like:

11:53:51 [emerg] 12781#12781: the duplicate "host" variable in /tmp/nginx/nginx-cfg350749497:710

I can’t find any restrictions are imposed on the redefinition of core variables in nginx...

  • It does not work that way. You will mostly want to sent this to a proxy you using. So in your `proxy_pass` section you should use `proxy_set_headers $http_x-real-host;` – Tarun Lalwani Feb 09 '23 at 15:26
  • If I add the `proxy_set_headers $http_x-real-host` block, then it will not work for me - upstream looks at the value of the `Host` header, which contains not the value of the real host, but the value of the fixed header set on the first proxy. – trltvski Feb 09 '23 at 15:40
  • So I need the variable `$host` to contain the value of the real host, which is in `$http_x_real_host`. – trltvski Feb 09 '23 at 15:48
  • Sorry it should be `proxy_set_headers Host $http_x-real-host;` – Tarun Lalwani Feb 09 '23 at 16:16

0 Answers0