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 '20 at 06: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 '20 at 06: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 '20 at 06:30
  • @RichardSmith thanx – Vasil Akhmetov Jun 15 '20 at 08: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 '20 at 15:53
  • @MichaelHampton anyway IIS looks on the Host header and then don't see known value in bindings and returns 400 invalid hostname. Documentation clarify meaning of host header https://httpwg.org/specs/rfc7230.html#header.host . – Vasil Akhmetov Jun 16 '20 at 07:20

0 Answers0