3

Running nginx on windows as reverse proxy with the below nginx.conf

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       8082;
        server_name  localhost;

        location / {
            proxy_pass http://192.168.12.211:8082;
            proxy_redirect http://192.168.12.211/ http://localhost:8080/;
            proxy_set_header   Host $host;
        }
    }
}

Here is the curl o/p.

c:\curl>curl -I http://localhost:8082
HTTP/1.1 303 See Other
Server: nginx/1.9.9
Date: Wed, 20 Jan 2016 10:30:38 GMT
Content-Type: text/html
Connection: keep-alive
Access-Control-Allow-Origin: *
location: http://192.168.12.211:8080/test.htm?Id=12345678

I want the "location" header received in the response to be rewritten as shown in the proxy_redirect directive in the nginx.conf file. Basically

location: http://192.168.12.211:8080/test.htm?Id=12345678

must be rewritten as

location: http://localhost:8080/test.htm?Id=12345678

What am I missing here in the nginx configuration? Any hints appreciated.

sthustfo
  • 1,209
  • 4
  • 19
  • 35

0 Answers0