I run several docker containers with hostnames:
web1.local web2.local web3.local
Routing to these done based on hostname by nginx. I have a proxy in front of this setup (on different machine connected to internet) where I define upstream as:
upstream main {
server web1.local:80;
server web2.local:80;
server web3.local:80;
}
And actual virtual host description:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://main;
}
}
Now, because containers receive hostname "main" instead of "web1.local", they do not respond properly to the request.
Question: how I can tell nginx to pass name of the upstream server instead of name of upstream group of servers in Host: header when proxying request?