0

I configured simple load balancer scheme on the windows:

upstream app.local {
    server app1.local:8001 fail_timeout=10s max_fails=10;
    server app2.local:8002 fail_timeout=10s max_fails=10;
}

server {
    listen 8000;

    location / {
        proxy_pass http://app.local;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
    }
}

Changed hosts file like this

127.0.0.1       app.local
127.0.0.1       app1.local
127.0.0.1       app2.local

All fine, but my web servers behind app1.local and app2.local receive incorrect headers Host: app.local and therefore don't want resolve requests. I readed the post where the same problem but top answer not resolved my and i don't want to use the double layer proxy option straight off.

  • What were you expecting to happen? – Michael Hampton Jun 15 at 6:01
  • @MichaelHampton I'm expecting that my http servers from upstream will receive correct host in header app1.local or app2.local. So they can resolve and process request. They are receiving app.local now. – Vasil Akhmetov Jun 15 at 6:09
  • You want Nginx to change the value of the Host header to whichever server is selected from the upstream block. Unfortunately, I don't think it's possible. – Richard Smith Jun 15 at 6:30
  • @RichardSmith thanx – Vasil Akhmetov Jun 15 at 8:09
  • That's not what the Host header is for! The Host header indicates the domain name in the URL that the client requested, e.g. www.yandex.ru or whatever. – Michael Hampton Jun 15 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.