upstream
does not work when the proxyed server has more than one host name binding on the same port.
I ran into this issue while trying to configure nginx (1.9.12-1~trusty) to proxy_pass
a Windows Server 2012 host.
I have reproduced the same behavior on my own Windows 10 machine.
In the below configuration all host names point to the same machine IP.
Requests work sometimes
Note: I exepect this is when localhost:7778
is choosen to be proxyed.
http {
upstream w {
server test1:80;
server test2:80;
server localhost:7778;
}
server {
listen 8001;
server_name localhost;
location / {
proxy_pass http://w;
}
}
}
Requests work none of the time
Note: edited as pointed out by Alexey.
http {
upstream w {
server test1:80;
server test2:80;
# server localhost:7778;
}
server {
listen 8001;
server_name localhost;
location / {
proxy_pass http://w;
}
}
}
Requests work all the time
http {
server {
listen 8001;
server_name localhost;
location / {
proxy_pass http://test1:80;
}
}
}
or
http {
server {
listen 8001;
server_name localhost;
location / {
proxy_pass http://test2:80;
}
}
}
or
http {
server {
listen 8001;
server_name localhost;
location / {
proxy_pass http://localhost:7778;
}
}
}
Is there a way around this?