Nginx reverse proxy and IIS

iisnginxreverse-proxy

I'm using nginx as a reverse proxy for website running on IIS 7.5. Website is bound to sub-1.foo.bar. Nginx configuration looks like this:

server {
    listen 80;

    server_name sub.foo.bar;

    location / {
        proxy_pass http://sub-1.foo.bar;
        proxy_set_header Host $host;
        proxy_set_header X-Accel-Expires 0;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

What I want to do is forward requests which come to sub.foo.bar (linux machine with nginx) to sub-1.foo.bar (windows machine with IIS and my website). However what happens is

  • when I access sub.foo.bar, I get 404 page
  • when I access sub-1.foo.bar directly I get my website served normally from IIS
  • nginx seems to forward requests normally to windows machine
  • I can't see any incoming requests from IIS logs when I access sub.foo.bar
  • when I add binding for sub.foo.bar on IIS, website gets proxied normally with nginx

I would appreciate any ideas on what might be wrong with my setup. Thanks!

Best Answer

Try to manually add proxy_set_header Host "sub-1.foo.bar"

Related Topic