0

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?

RalfFriedl
  • 3,008
  • 4
  • 12
  • 17
Radaeld
  • 1
  • 1
  • 3
  • a typo here perhaps (or maybe the issue) > location \ { ... } the \ (backslash) is an escape character there, shouldn't be "/"? – ignivs Jan 29 '19 at 19:11
  • rip im dead. That was the forwarding problem. Although now i have a new error. Connection refuse. After using nmap to check if the exposed port of the container is open it seems filtered the 5000. As a result is refusinghte connection :/ – Radaeld Jan 29 '19 at 19:58

1 Answers1

1

the location should be / not \

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

Kerolos William
  • 305
  • 1
  • 13
  • yea it was /. I the ip is correct since they are inside the same net work. But getting connection refused now (tried the docker ip of te network and did not work too just to be safe). New problem pop up. – Radaeld Jan 29 '19 at 20:21
  • what's the output of you trying to telnet from inside the container to the other one's IP and port ? – Kerolos William Jan 30 '19 at 09:50
  • # telnet n2 5000 Trying 172.18.0.3... telnet: Unable to connect to remote host: Connection refused – Radaeld Jan 30 '19 at 15:05
  • are you using publish or expose for the docker ports you can check the following URL for more help https://nickjanetakis.com/blog/docker-tip-59-difference-between-exposing-and-publishing-ports – Kerolos William Jan 30 '19 at 15:56
  • expose since its the same network, testing inside the nginx container – Radaeld Jan 30 '19 at 15:59