0
I am setting up a reverse proxy with Nginx + Docker.
I have 02 machines that are in the bridge network.
proxy : 172.17.0.2 app : 172.17.0.3
Both containers are configured with name
server {
listen 80;
server_name portainer.domain;
location / {
proxy_pass http://localhost:9000;
proxy_redirect off;
proxy_bind 127.0.0.1;
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;
client_max_body_size 0;
}
}
With this setting when accessing http://portainer.domain
I get error 502 - Bad Gateway.
When I switch to IP forwarding as below works perfectly.
server {
listen 80;
server_name portainer.domain;
location / {
proxy_pass http://172.17.0.3:9000;
proxy_redirect off;
proxy_bind 127.0.0.1;
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;
client_max_body_size 0;
}
Both containers are in the default bridge network.
If I connect in the console of both containers I can drip by IP, but not by container name.
On host machine I also cannot drip by container name, only by IP.
I’ve tried to put too proxy_pass http://portainer:9000;
, where portainer is the container name I wish to access and did not succeed.
The client machine is accessing the reverse proxy server normally, the problem is time the proxy server forwards the request internally.