Nginx-proxy: Error only with Subdomain 502 Bad gateway

Created on 15 Dec 2018  路  3Comments  路  Source: nginx-proxy/nginx-proxy

Hello everyone . I need your help . I tried all the solutions proposed in the nginx-proxy docker and alternative solutions on google, nothing changes.
How to fix this problem.

i have 2 servers :

> S1: Docker CE:
>         Nginx-proxy
>         Letsencryp
>         Emby
>         Ombi (I had problems to validate it)
>         Deluge (web access impossible functional daemon)
>         (I did not manage to install organizr, and/or heimdall)
>         OS: Ubuntu 18.04 lts
> 
>         S2: Docker CE:
>         Nginx-proxy
>         Letsencryp
>         Subsonic
>         Transmission
>         (I was unable to install organizr and/or heimdall)
>         OS: Ubuntu 16.04 lts
`nginx.1    | 2018/12/12 10:46:12 [error] 221#221: *8607 no live upstreams while connecting to upstream, client: 77.147.234.230, server: heimdall.nomdedomain.com, request: "GET / HTTP/2.0", upstream: "http://heimdall.nomdedomaine.com/", host: "heimdall.nomdedomaine.com"
nginx.1    | heimdall.nomdedomaine.com 77.147.234.230 - - [12/Dec/2018:10:46:12 +0000] "GET / HTTP/2.0" 502 173 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0"
nginx.1    | 2018/12/12 10:46:13 [error] 221#221: *8607 no live upstreams while connecting to upstream, client: 77.147.234.230, server: heimdall.nomdedomaine.com, request: "GET /favicon.ico HTTP/2.0", upstream: "http://heimdall.nomdedomaine.com/favicon.ico", host: "heimdall.nomdedomaine.com"
nginx.1    | heimdall.nomdedomaine.com 77.147.234.230 - - [12/Dec/2018:10:46:13 +0000] "GET /favicon.ico HTTP/2.0" 502 173 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0"
nginx.1    | ombi.nomdedomaine.com 77.147.234.230 - - [12/Dec/2018:10:46:13 +0000] "GET /favicon.ico HTTP/2.0" 404 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0"
nginx.1    | 2018/12/12 10:49:27 [error] 221#221: *8612 upstream prematurely closed connection while reading response header from upstream, client: 77.147.234.230, server: deluge.nomdedomaine.com, request: "GET / HTTP/2.0", upstream: "http://172.17.0.4:8112/", host: "deluge.nomdedomaine.com"
nginx.1    | deluge.nomdedomaine.com 77.147.234.230 - - [12/Dec/2018:10:49:27 +0000] "GET / HTTP/2.0" 502 173 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0"
nginx.1    | 2018/12/12 10:49:27 [error] 221#221: *8612 upstream prematurely closed connection while reading response header from upstream, client: 77.147.234.230, server: deluge.nomdedomaine.com, request: "GET /favicon.ico HTTP/2.0", upstream: "http://172.17.0.4:8112/favicon.ico", host: "deluge.nomdedomaine.com"

my docker

docker run -d -p 80:80 -p 443:443 \
      --name nginx-proxy\
      --restart always \
      -e DEFAULT_HOST=nomdedomain.com \
      -v /home/user/docker/nginx-proxy/certs:/etc/nginx/certs:ro \
      -v /home/user/docker/nginx-proxy/dhparam:/etc/nginx/dhparam \
      -v /etc/nginx/vhost.d \
      -v /etc/nginx/conf.d \
      -v /usr/share/nginx/html \
      -v /var/run/docker.sock:/tmp/docker.sock:ro \
      --label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy \
       jwilder/nginx-proxy:latest

`docker run -d
--name=heimdall
--restart always
-v /home/madameko/docker/heimdall/config:/config
-e PUID=1001
-e PGID=1001
-p 33480:33480
-e TZ=Europe/Paris
-e "VIRTUAL_PORT=33480"
-e "VIRTUAL_HOST=heimdall.seedboxren.com"
-e "LETSENCRYPT_HOST=heimdall.seedboxren.com"
-e "[email protected]"
linuxserver/heimdall

[
{
"Id": "2fa58f3efb73f5d53f732f53196dd58c334fce6df38df4c057413ceb3c163449",
"Created": "2018-12-13T18:11:39.722658114Z",
"Path": "/init",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 27008,
"ExitCode": 0,
"Error": "",
"StartedAt": "2018-12-13T18:11:40.291436248Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:12cb0d29e8cb537403c685c5f6cbfffc93aabe31bd19fb737776144d840e484c",
"ResolvConfPath": "/var/lib/docker/containers/2fa58f3efb73f5d53f732f53196dd58c334fce6df38df4c057413ceb3c163449/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/2fa58f3efb73f5d53f732f53196dd58c334fce6df38df4c057413ceb3c163449/hostname",
"HostsPath": "/var/lib/docker/containers/2fa58f3efb73f5d53f732f53196dd58c334fce6df38df4c057413ceb3c163449/hosts",
"LogPath": "/var/lib/docker/containers/2fa58f3efb73f5d53f732f53196dd58c334fce6df38df4c057413ceb3c163449/2fa58f3efb73f5d53f732f53196dd58c334fce6df38df4c057413ceb3c163449-json.log",
"Name": "/heimdall",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/home/madameko/docker/heimdall/config:/config"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"33480/tcp": [
{
"HostIp": "",
"HostPort": "33480"
}
]
},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/asound",
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/ec17a5146638b822117ee81a38b7c851535085a359c89c9aa1043f275d36540c-init/diff:/var/lib/docker/overlay2/01d52b3ee46e67ec32242eb1c1e9e82d2770af1c69e5979fb8a4e5d2f7e3888c/diff:/var/lib/docker/overlay2/fb7266e944f040fd073a20d96a5b7184e3464dfddd3c0f84f2a331d0c876b0ee/diff:/var/lib/docker/overlay2/0c0d7d4732c4d4b62448cd8ce292c64e6d28b5c5b58b7631075a8ce493e34f33/diff:/var/lib/docker/overlay2/1df8cd3e15b53bd261a3c6baca595ac0a448070a253422994aac2ffe3cc1c7be/diff:/var/lib/docker/overlay2/54204d450ae159d78df68ca73ac4db2745cec00bdf085267364666a752cb27fd/diff:/var/lib/docker/overlay2/0cc705fa7e05f2a9539efc24d94f0c8f0b49d9c7a6647b70fbe0902160c70d7c/diff:/var/lib/docker/overlay2/f6555c0352a7d9b3f9c64c43ecd11c3afcbd79cd4e3de4af944b7d853d9eca0c/diff",
"MergedDir": "/var/lib/docker/overlay2/ec17a5146638b822117ee81a38b7c851535085a359c89c9aa1043f275d36540c/merged",
"UpperDir": "/var/lib/docker/overlay2/ec17a5146638b822117ee81a38b7c851535085a359c89c9aa1043f275d36540c/diff",
"WorkDir": "/var/lib/docker/overlay2/ec17a5146638b822117ee81a38b7c851535085a359c89c9aa1043f275d36540c/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/home/madameko/docker/heimdall/config",
"Destination": "/config",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "2fa58f3efb73",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"33480/tcp": {},
"443/tcp": {},
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"VIRTUAL_PORT=33480",
"VIRTUAL_HOST=heimdall.seedboxren.com",
"LETSENCRYPT_HOST=heimdall.seedboxren.com",
"[email protected]",
"PUID=1001",
"PGID=1001",
"TZ=Europe/Paris",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"PS1=$(whoami)@$(hostname):$(pwd)$ ",
"HOME=/root",
"TERM=xterm",
"S6_BEHAVIOUR_IF_STAGE2_FAILS=2"
],
"Cmd": null,
"Image": "linuxserver/heimdall",
"Volumes": {
"/config": {}
},
"WorkingDir": "",
"Entrypoint": [
"/init"
],
"OnBuild": null,
"Labels": {
"build_version": "Linuxserver.io version:- 2.1.12-ls20 Build-date:- 2018-12-11T12:53:40+00:00",
"maintainer": "aptalca"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "40fde78fa0e80833d7611b4f42659be94057ed8ac6e85b88f7464a4bcf7357b7",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"33480/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "33480"
}
],
"443/tcp": null,
"80/tcp": null
},
"SandboxKey": "/var/run/docker/netns/40fde78fa0e8",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "defde0f6944a7fbf1819d878fa684d96e12754b48d1ee367c1e2057df184d41c",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.5",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:05",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "702c5a76077b714e8b3eabe2d530c8e5cac1914917e83f7b9e1c215ca6d56a5c",
"EndpointID": "defde0f6944a7fbf1819d878fa684d96e12754b48d1ee367c1e2057df184d41c",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.5",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:05",
"DriverOpts": null
}
}
}
}
]`

I did the max test the container are ok, the ports are ok (I think)

I tried this tutorial but I can not do that the file is read loading the container.
https://wiki.ssdt-ohio.org/display/rtd/Adjusting+nginx-proxy+Timeout+Configuration

Any help is welcome . Thank you all

Most helpful comment

Could you show output of command

docker exec nginx-proxy cat /etc/nginx/conf.d/default.conf

I have the same problem, but in my case, I forgot set VIRTUAL_PORT so upstream server could not be serve on right port. Added it make my containers worked well

All 3 comments

Could you show output of command

docker exec nginx-proxy cat /etc/nginx/conf.d/default.conf

I have the same problem, but in my case, I forgot set VIRTUAL_PORT so upstream server could not be serve on right port. Added it make my containers worked well

Hey @picosix - late to this party but where exactly did you specify VIRTUAL_PORT? Sorry for the dumbness. Coming back to docker after sometime away.

Hello there.

I'll post here the result of my:

docker exec nginx-proxy cat /etc/nginx/conf.d/default.conf

Here it is:

# 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 X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port {
  default $http_x_forwarded_port;
  ''      $server_port;
}
# 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;
}
# Apply fix for very long server names
server_names_hash_bucket_size 128;
# Default dhparam
ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl {
  default off;
  https on;
}
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;
resolver 127.0.0.11;
# 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;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
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;
}
server {
    server_name _; # This is just an invalid value which will never trigger on a real hostname.
    listen 443 ssl http2;
    access_log /var/log/nginx/access.log vhost;
    return 503;
    ssl_session_tickets off;
    ssl_certificate /etc/nginx/certs/default.crt;
    ssl_certificate_key /etc/nginx/certs/default.key;
}
# sectorasegurador.local
upstream sectorasegurador.local {
                ## Can be connected with "nginxproxy_default" network
            # wp_sectorasegurador.local
            server 172.22.0.3:3001;
}
server {
    server_name sectorasegurador.local;
    listen 80 ;
    access_log /var/log/nginx/access.log vhost;
    include /etc/nginx/vhost.d/default;
    location / {
        proxy_pass http://sectorasegurador.local;
    }
}
server {
    server_name sectorasegurador.local;
    listen 443 ssl http2 ;
    access_log /var/log/nginx/access.log vhost;
    return 500;
    ssl_certificate /etc/nginx/certs/default.crt;
    ssl_certificate_key /etc/nginx/certs/default.key;
}

And I'm getting the same problem as here... connection refused and 502.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

etiennemtl picture etiennemtl  路  3Comments

strech345 picture strech345  路  4Comments

nickjanssen picture nickjanssen  路  3Comments

TravisDart picture TravisDart  路  3Comments

sjawhar picture sjawhar  路  4Comments