How can I fix this 502 Bad Gateway?
See original GitHub issue!!!PLEASE READ!!!
Questions
If you have a question, DO NOT SUBMIT a new issue. Please ask the question on the Q&A Group: https://groups.google.com/forum/#!forum/nginx-proxy
google group is shows “Content unavailable”. There is no place to join that group of view previous issues.
Bugs or Features
I am trying to run a WordPress site inside of a docker container on Ubuntu VPS using Nginx-Proxy.
I created the following docker-compose.yml
file
version: '3.4'
services:
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- 80:80
- 443:443
restart: always
networks:
- external
volumes:
- wordpress:/var/www/html
ports:
- 5500:5500
wordpress_app:
image: wordpress
restart: always
environment:
- VIRTUAL_HOST=sub.domain.com
- VIRTUAL_PORT=5500
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=db_username
- WORDPRESS_DB_PASSWORD=db_password
- WORDPRESS_DB_NAME=db_name
depends_on:
- nginx-proxy
- db
networks:
- internal
- external
volumes:
- wordpress:/var/www/html
ports:
- 5500:5500
db:
image: mysql:latest
restart: always
hostname: mysql
environment:
- VIRTUAL_PORT=3306
- MYSQL_DATABASE=db_name
- MYSQL_USER=db_username
- MYSQL_PASSWORD=db_password
- MYSQL_ROOT_PASSWORD=root_password
networks:
- internal
volumes:
- db:/var/lib/mysql
ports:
- 3306:3306
volumes:
wordpress:
db:
networks:
internal:
external:
Now, executing docker-compose up
prints the following
Attaching to root_db_1, root_nginx-proxy_1, root_wordpress_app_1
db_1 | 2020-10-12 16:34:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
db_1 | 2020-10-12 16:34:18+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1 | 2020-10-12 16:34:18+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
db_1 | 2020-10-12T16:34:19.127860Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21) starting as process 1
db_1 | 2020-10-12T16:34:19.146953Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
db_1 | 2020-10-12T16:34:20.318195Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
nginx-proxy_1 | WARNING: /etc/nginx/dhparam/dhparam.pem was not found. A pre-generated dhparam.pem will be used for now while a new one
nginx-proxy_1 | is being generated in the background. Once the new dhparam.pem is in place, nginx will be reloaded.
nginx-proxy_1 | forego | starting dockergen.1 on port 5000
nginx-proxy_1 | forego | starting nginx.1 on port 5100
nginx-proxy_1 | dockergen.1 | 2020/10/12 16:34:18 Generated '/etc/nginx/conf.d/default.conf' from 2 containers
nginx-proxy_1 | dockergen.1 | 2020/10/12 16:34:18 Watching docker events
nginx-proxy_1 | dockergen.1 | 2020/10/12 16:34:20 Generated '/etc/nginx/conf.d/default.conf' from 3 containers
nginx-proxy_1 | dockergen.1 | 2020/10/12 16:34:20 Received event start for container a6b94da9d7a7
nginx-proxy_1 | dockergen.1 | 2020/10/12 16:34:20 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
db_1 | 2020-10-12T16:34:20.960375Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
db_1 | 2020-10-12T16:34:21.394031Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
db_1 | 2020-10-12T16:34:21.394509Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
db_1 | 2020-10-12T16:34:21.425181Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db_1 | 2020-10-12T16:34:21.566194Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
wordpress_app_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.25.0.3. Set the 'ServerName' directive globally to suppress this message
wordpress_app_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.25.0.3. Set the 'ServerName' directive globally to suppress this message
wordpress_app_1 | [Mon Oct 12 16:34:22.661957 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.11 configured -- resuming normal operations
wordpress_app_1 | [Mon Oct 12 16:34:22.662180 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
nginx-proxy_1 | 2020/10/12 16:34:23 [notice] 49#49: signal process started
nginx-proxy_1 | Generating DH parameters, 2048 bit long safe prime, generator 2
nginx-proxy_1 | This is going to take a long time
nginx-proxy_1 | dhparam generation complete, reloading nginx
Then when I make a request to http://sub.domain.com I get the 502 error but I also get this in the server’s log
nginx-proxy_1 | nginx.1 | 2020/10/12 16:35:07 [error] 51#51: *1 connect() failed (111: Connection refused) while connecting to upstream, client: MY_PERSOANL_IP_ADDRESS, server: sub.domain.com, request: "GET / HTTP/1.1", upstream: "http://172.25.0.3:5500/", host: "sub.domain.com"
nginx-proxy_1 | nginx.1 | sub.domain.com MY_PERSOANL_IP_ADDRESS - - [12/Oct/2020:16:35:07 +0000] "GET / HTTP/1.1" 502 157 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0"
nginx-proxy_1 | nginx.1 | sub.domain.com MY_PERSOANL_IP_ADDRESS - - [12/Oct/2020:16:35:08 +0000] "GET /favicon.ico HTTP/1.1" 502 157 "http://sub.domain.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0"
nginx-proxy_1 | nginx.1 | 2020/10/12 16:35:08 [error] 51#51: *1 no live upstreams while connecting to upstream, client: MY_PERSOANL_IP_ADDRESS, server: sub.domain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://sub.domain.com/favicon.ico", host: "sub.domain.com", referrer: "http://sub.domain.com/"
Potential Issue
The logs states
2020/10/12 16:34:20 Generated ‘/etc/nginx/conf.d/default.conf’ from 3 containers
However, while docker containers are running, I execute cd /etc/nginx/conf.d
but I get -bash: cd: /etc/nginx/conf.d/: No such file or directory.
Should the file /etc/nginx/conf.d/default.conf
actually exists?
What can be causing this issue? How can I fix it?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
@tkw1536 Thank you for you assistance. I have improved the
docker-compose.yml
file to the followingAdditionally, in the
/etc/certificates
path, I have the following 4 files for the https certificateWhen browsing http://usa.domain.com I get the “503 Service Temporarily Unavailable” error. At the same time, when browsing https://usa.domain.com I get a white page.
Any idea on what could be causing the 503 error now?
Could you share your config? I’m having this exact same issue in #2049