proxy_pass not passing to dynamic $host

nehay2j nginx-forum at
Sat Nov 2 01:45:18 UTC 2013


I did a curl on the url - curl -i

HTTP/1.1 302 Found
Date: Sat, 02 Nov 2013 01:37:47 GMT
Server: nginx/1.4.2
Content-Length: 0
Connection: keep-alive

Which is correct. But when I submit post request through browser, I gives me
a 404 with no error in logs. Should i be using rewrite command here or not?
If I remove rewrite command, it give file not found error as it picks
default root path always.

2013/11/01 20:35:08 [error] 17339#0: *11 open()
"/opt/nginx/html/test/main.html" failed (2: No such file or directory
), client:,, request: "GET /test/main.html
HTTP/1.1", host: "", referrer:

location ~ /(?<ec2instance>[0-9].*) {
#                alias http://$ec2instance:8080/test;
#               try_files $uri;
               rewrite  $(.*)$ https://$http_host:8080/test break;
                proxy_pass http://$ec2instance:8080/test;
                proxy_read_timeout 300;
                proxy_connect_timeout 300;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For


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

More information about the nginx mailing list