0
votes

so I'm having docker container using node application (which is working for 100%) on port 7001. I would like to access this app from localhost:8090 but unfortunately I'm receiving 502 bad gateway error. Docker run command with ports mapping is also working properly. There must be an error in nginx config. I appreciate any idea. Since I have few apps my nginx looks like: nginx.conf:

user root;

worker_processes 2;

events {
  worker_connections 1024;
}

http {
  include mime.types;
  default_type application/octet-stream;

  sendfile on;

  keepalive_timeout 65;

  include /etc/nginx/sites-enabled/*;
}

daemon off;

The app which is causing troubles (/etc/nginx/sites-enabled/third-page):

server {
        listen      8090;
        root        /usr/bin;
        server_name localhost;
        access_log  /dev/null;
        error_log   /dev/null;

        location / {
                proxy_pass http://127.0.0.0:7001;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Fowarded-Proto $scheme;
                proxy_cache_bypass $http_upgrade;

               try_files $uri $uri/ =404;
        }

        location ~ \.(gif) {
                root /var/lib;
        }

}

Info from error.log:

2021/01/18 16:07:14 [error] 744#744: *175 connect() to 127.0.0.0:7001 failed (101: Network unreachable) while connecting to upstream, client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.0:7001/", host: "localhost:8090", referrer: "http://localhost:8080/"
1
Where exactly is the node application running?tkausl
The node application is located in /usr/app.js and I run it manually from inside of the container - it's more like training while learning docker and nginx. I know it's bad solution in real life scenario.Robert Kwiatkowski
Show how do you start the container. docker run ...Dr Claw

1 Answers

0
votes

Run netstat and check if anything is using port 7001 also change http://127.0.0.0 to http://127.0.0.1 in proxy_pass