proxy_pass not passing to dynamic $host

nehay2j nginx-forum at
Fri Nov 1 21:16:11 UTC 2013

Thanks Francis. I could finally see the post parameters at server end.
Setting proxy_set_header Host $1; changes the browser url which we donot
want. Currently, the code looks like-

        location ~ /(?<ec2instance>[0-9].*) {
                rewrite  $(.*)$ https://$http_host/test last;
                proxy_pass http://$ec2instance:8080/test;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For


If i set 'proxy_set_header Host $http_host;'  to have $proxy_host instead of
$http_host, all other things work fine other than cookies. Cookies does not
get transferred. Having $http_host throws 404 error with the following entry
in log-

2013/11/01 21:05:37 [error] 17515#0: *1 open() "/opt/nginx/html/test" failed
(2: No such file or directory), client:, server:, request: "GET /testHTTP/1.1", host:
", referrer: ""

I will try to get the tcpdump of traffic.


Posted at Nginx Forum:,244308,244361#msg-244361

More information about the nginx mailing list