Nginx – Trying to redirect a docker container to another through nginx

dockerdocker-machinenginx

As the title say trying to reverse proxy.
Using an app with port 500 inside container with port exposed for 5000.
The nginx is on another container with port 80 exposed and publish to 8080.
Both containers are in the same network that I've created.

On Nginx container I've deleted the default.conf and created a new one
as follows:

server{
  listen 80;
  location \ {
    proxy_pass "http:0.0.0.0:5000";
    proxy_set_header Host $host;
    proxy_redirect          off;
    proxy_set_header        X-NginX-Proxy true;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

I also restarted the nginx so it starts with this .conf

when trying to access using the url: http://172.17.0.1:8080/ which is the gateway to the network i only get 404 not found.
On the Nginx container i get this message

"/etc/nginx/html/index.html" is not found (2: No such file or
directory), client: 172.17.0.1, server: , request: "GET / HTTP/1.1",
host: "172.17.0.1:8080"

Its like he is not redirecting only searching for the index file of the default.conf

Through nginx -T i can see that the configuration above is loaded.
Any one can help with the forwarding of this?

Best Answer

the location should be / not \

and also try to put the other container name or it's IP in the proxy_pass