in nginx.conf:
remind that in a nginx docker container 127.0.0.1 or localhost means the container itself.
nginx container consider all other container as individual hosts in the same network.
when a container's internal port is exposed to a host port, the "host" means docker's physical host operation system, not nginx's container!
so we can't use proxy-pass like "proxy-pass : 127.0.0.1:8080" because nginx docker will recognize "127.0.0.1" as itself.
instead we should use upstream like this:
upstream myweb {
server myweb:8080;
}
server {
listen 80;
location /myweb {
proxy_pass http://myweb;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}