seyyah
By:
seyyah

Nginx 502 Gateway Error with docker

August 16, 2017 500 views
Docker Nginx Ubuntu 16.04

I created the Docker 17.06.0-ce on 16.04 Droplet and composed hospitalrun-server docker container. I done DNS config, installed nginx and configured ufw.

Docker compose file is here. I run my docker container with,

$ cd ~/works/hospitalrun-server
$ docker-compose up --build -d

My dockers are healthy

docker ps
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                                                  NAMES
53704c8cba8d        hospitalrun_nginx      "/bin/sh -c /etc/n..."   2 hours ago         Up 2 hours          80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:8055->8080/tcp   hospitalrunserver_nginx_1
ea3888970ac8        hospitalrun            "/bin/sh -c ./entr..."   2 hours ago         Up 2 hours          3000/tcp                                               hospitalrun
fd8ad7612a5c        hospitalrun_logstash   "/usr/local/bin/do..."   15 hours ago        Up 2 hours          5044/tcp, 9600/tcp                                     logstash_hr
e837f6ba143e        couchdb:1.6            "tini -- /docker-e..."   15 hours ago        Up 2 hours          0.0.0.0:5985->5984/tcp                                 couchdb_hr

netstat' command's output is

$ netstat -plutn 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      17601/nginx -g daem
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1368/sshd       
tcp6       0      0 :::80                   :::*                    LISTEN      17601/nginx -g daem
tcp6       0      0 :::22                   :::*                    LISTEN      1368/sshd       
tcp6       0      0 :::8055                 :::*                    LISTEN      4012/docker-proxy
tcp6       0      0 :::443                  :::*                    LISTEN      4031/docker-proxy
tcp6       0      0 :::5985                 :::*                    LISTEN      3364/docker-proxy

My nginx configuration file is

worker_processes 1;

events { worker_connections 1024; }

http {
    upstream website {
        server 172.18.0.6:8055;
    }

    server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
        #server_name 185.14.187.134 app.bulut.dental;
        server_name app.bulut.dental;

        gzip_types text/plain text/css application/json application/x-javascript
                   text/xml application/xml application/xml+rss text/javascript;

        location / {
            proxy_pass http://website;
            #include /etc/nginx/proxy_params;
            #include /etc/nginx/mime.types;
        }
    }
}

Each http://185.14.187.134 and http://app.bulut.dental are produced the 502 gateway error. My nginx error' part is

2017/08/16 13:06:32 [error] 17602#17602: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 162.158.111.10, server: app.bulut.dental, request: "GET / HTTP/1.1", upstream: "http://172.18.0.6:8055/", host: "app.bulut.dental"

I tested successfully hospitalrun-server in local machine but i get error in my droplet.

Can you offer any guide or tutorial for production environment (specifically docker)? Thanks for your time and interest

Rel: https://github.com/HospitalRun/hospitalrun-server/issues/68

Be the first one to answer this question.