Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

502 bad gateway error #301

Closed
reyman opened this issue Nov 22, 2015 · 2 comments
Closed

502 bad gateway error #301

reyman opened this issue Nov 22, 2015 · 2 comments

Comments

@reyman
Copy link

reyman commented Nov 22, 2015

Hi,

I find multiple documentation about usage of nginx-proxy on the net, but when i try on my vps, i have a 502 gateway error with each image i test, don't understand why :

the docker -ps command return :

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                      NAMES
dca0d15c69bf        sharelatex/sharelatex   "/sbin/my_init"          2 minutes ago       Up 2 minutes        0.0.0.0:5000->80/tcp                       sharelatex
55ebd6b84a6a        osixia/phpldapadmin     "/container/tool/run"    3 days ago          Up 3 days           80/tcp, 443/tcp                            sleepy_thompson
e8fe2bd50c3a        osixia/openldap         "/container/tool/run"    3 days ago          Up 3 days           389/tcp, 636/tcp                           dreamy_babbage
9597ef0cded5        jwilder/nginx-proxy     "/app/docker-entrypoi"   3 days ago          Up 3 days           0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   pensive_raman

I create the sharelatex image with and without VIRTUAL_PORT option :

sudo docker run -d -e "VIRTUAL_HOST=latex.comnmodel.org" -e "VIRTUAL_PORT=80" -v ~/sharelatex_data:/var/lib/sharelatex -p 5000:80 --name=sharelatex sharelatex/sharelatex

The docker exec pensive_raman grep -vE '^\s*$' /etc/nginx/conf.d/default.conf return

# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
  default $http_x_forwarded_proto;
  ''      $scheme;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
  default upgrade;
  '' close;
}
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
log_format vhost '$host $remote_addr - $remote_user [$time_local] '
                 '"$request" $status $body_bytes_sent '
                 '"$http_referer" "$http_user_agent"';
access_log off;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
server {
        server_name _; # This is just an invalid value which will never trigger on a real hostname.
        listen 80;
        access_log /var/log/nginx/access.log vhost;
        return 503;
}
upstream latex.comnmodel.org {
                        # sharelatex
                        server 172.17.0.5:80;
}
server {
        server_name latex.comnmodel.org;
        listen 80 ;
        access_log /var/log/nginx/access.log vhost;
        location / {
                proxy_pass http://latex.comnmodel.org;
        }
}
upstream ldap.comnmodel.org {
                        # sleepy_thompson
                        server 172.17.0.4:80;
}
server {
        server_name ldap.comnmodel.org;
        listen 80 ;
        access_log /var/log/nginx/access.log vhost;
        location / {
                proxy_pass http://ldap.comnmodel.org;
        }
}

When i ping latex.comnmodel.org located on my vps ip 51.255.47.40 :

PING latex.comnmodel.org (51.255.47.40) 56(84) bytes of data.
64 bytes from 40.ip-51-255-47.eu (51.255.47.40): icmp_seq=1 ttl=50 time=14.6 ms
64 bytes from 40.ip-51-255-47.eu (51.255.47.40): icmp_seq=2 ttl=50 time=12.9 ms
64 bytes from 40.ip-51-255-47.eu (51.255.47.40): icmp_seq=3 ttl=50 time=13.6 ms

The docker logs pensive_raman return

...
nginx.1    | latex.comnmodel.org 81.64.146.124 - - [22/Nov/2015:22:40:23 +0000] "GET / HTTP/1.1" 502 181 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0"
nginx.1    | latex.comnmodel.org 81.64.146.124 - - [22/Nov/2015:22:40:26 +0000] "GET / HTTP/1.1" 502 181 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0"
nginx.1    | latex.comnmodel.org 81.64.146.124 - - [22/Nov/2015:22:40:32 +0000] "GET / HTTP/1.1" 502 181 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0"

The website latex.comnmodel.org return a 502 bad gateway, what i miss here, this is very frustrating :(

@reyman
Copy link
Author

reyman commented Nov 24, 2015

I crosspost on stackoverflow, i also remark that the sharelatex container cannot be ping from the nginx-proxy container, this is normal ?

@wader
Copy link

wader commented Nov 24, 2015

@reyman could be ICC related? i answered your question on SO about that

@jwilder jwilder closed this as completed Mar 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants