[GH-ISSUE #374] Docker-compose template (Bad Gateway) FIX #318

Closed
opened 2026-02-26 06:32:14 +03:00 by kerem · 1 comment
Owner

Originally created by @theraw on GitHub (Apr 16, 2020).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/374

Executed

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - ./config.json:/app/config/production.json
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db
  db:
    image: 'jc21/mariadb-aria:10.4'
    environment:
      MYSQL_ROOT_PASSWORD: '123456789'
      MYSQL_DATABASE: 'nginx'
      MYSQL_USER: 'raw'
      MYSQL_PASSWORD: '123456789'
    volumes:
      - ./data/mysql:/var/lib/mysql

right after that on port 81 i can't login as admin and i get the error
login.bundle.js?v=2.2.3:25 POST http://1.1.1.1:81/api/tokens 502 (Bad Gateway)

Now this command
node --abort_on_uncaught_exception --max_old_space_size=250 index.js
Gives the error

[root@docker-dd466fd29d69:/app]# node --abort_on_uncaught_exception --max_old_space_size=250 index.js
[4/16/2020] [2:14:49 PM] [Global   ] › ✖  error     connect ECONNREFUSED 127.0.0.1:3306
[4/16/2020] [2:14:50 PM] [Global   ] › ✖  error     connect ECONNREFUSED 127.0.0.1:3306
[4/16/2020] [2:14:51 PM] [Global   ] › ✖  error     connect ECONNREFUSED 127.0.0.1:3306
[4/16/2020] [2:14:52 PM] [Global   ] › ✖  error     connect ECONNREFUSED 127.0.0.1:3306

i don't understand depends_on however in other hand i can show you a different way how to reach this with private static ip.
my yml

version: '3.7'
services:
  nginx:
    container_name: nginx
    ports:
     - "0.0.0.0:80:80"
     - "0.0.0.0:81:81"
     - "0.0.0.0:443:443"
    image: "jc21/nginx-proxy-manager:latest"
    shm_size: '512MB'
    privileged: true
    restart: unless-stopped
    networks:
      nginx_net:
        ipv4_address: 172.55.0.70
    dns:
     - "1.1.1.1"
     - "1.1.0.0"
    ulimits:
     nproc: 65535
    cap_add:
     - "CAP_SYS_RESOURCE"
     - "CAP_SYS_TIME"
    volumes:
      - ./config.json:/app/config/production.json
      - /NPM/data:/data
      - /NPM/letsencrypt:/etc/letsencrypt
  db:
    container_name: db
    image: 'jc21/mariadb-aria:10.4'
    shm_size: '512MB'
    privileged: true
    restart: unless-stopped
    ports:
      - '3306:3306'
    networks:
      nginx_net:
        ipv4_address: 172.55.0.72
    dns:
     - "1.1.1.1"
     - "1.1.0.0"
    ulimits:
     nproc: 65535
    cap_add:
     - "CAP_SYS_RESOURCE"
     - "CAP_SYS_TIME"
    environment:
      MYSQL_ROOT_PASSWORD: '1234567890'
      MYSQL_DATABASE: 'nginx'
      MYSQL_USER: 'raw'
      MYSQL_PASSWORD: '123456789'
    volumes:
      - /NPM/data/mysql:/var/lib/mysql
networks:
  nginx_net:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
      - subnet: 172.55.0.0/16

Now that we've set a static ip for each container and we have the mysql ip 172.55.0.72 config file will be

{
  "database": {
    "engine": "mysql",
    "host": "172.55.0.72",
    "name": "nginx",
    "user": "raw",
    "password": "123456789",
    "port": 3306
  }
}
root@server651029:~# docker-compose -f docker-compose.yml up -d
Creating network "root_nginx_net" with driver "bridge"
Creating nginx ... done                                                                                                 
Creating db    ... done 

root@server651029:~# curl -s 'http://1.1.1.1:81/api/tokens'
{"error":{"code":400,"message":"Internal Error"}}
Originally created by @theraw on GitHub (Apr 16, 2020). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/374 Executed ```yml version: '3' services: app: image: 'jc21/nginx-proxy-manager:latest' ports: - '80:80' - '81:81' - '443:443' volumes: - ./config.json:/app/config/production.json - ./data:/data - ./letsencrypt:/etc/letsencrypt depends_on: - db db: image: 'jc21/mariadb-aria:10.4' environment: MYSQL_ROOT_PASSWORD: '123456789' MYSQL_DATABASE: 'nginx' MYSQL_USER: 'raw' MYSQL_PASSWORD: '123456789' volumes: - ./data/mysql:/var/lib/mysql ``` right after that on port `81` i can't login as admin and i get the error ```login.bundle.js?v=2.2.3:25 POST http://1.1.1.1:81/api/tokens 502 (Bad Gateway)``` Now this command `node --abort_on_uncaught_exception --max_old_space_size=250 index.js` Gives the error ```nodejs [root@docker-dd466fd29d69:/app]# node --abort_on_uncaught_exception --max_old_space_size=250 index.js [4/16/2020] [2:14:49 PM] [Global ] › ✖ error connect ECONNREFUSED 127.0.0.1:3306 [4/16/2020] [2:14:50 PM] [Global ] › ✖ error connect ECONNREFUSED 127.0.0.1:3306 [4/16/2020] [2:14:51 PM] [Global ] › ✖ error connect ECONNREFUSED 127.0.0.1:3306 [4/16/2020] [2:14:52 PM] [Global ] › ✖ error connect ECONNREFUSED 127.0.0.1:3306 ``` i don't understand `depends_on` however in other hand i can show you a different way how to reach this with private static ip. my yml ```yml version: '3.7' services: nginx: container_name: nginx ports: - "0.0.0.0:80:80" - "0.0.0.0:81:81" - "0.0.0.0:443:443" image: "jc21/nginx-proxy-manager:latest" shm_size: '512MB' privileged: true restart: unless-stopped networks: nginx_net: ipv4_address: 172.55.0.70 dns: - "1.1.1.1" - "1.1.0.0" ulimits: nproc: 65535 cap_add: - "CAP_SYS_RESOURCE" - "CAP_SYS_TIME" volumes: - ./config.json:/app/config/production.json - /NPM/data:/data - /NPM/letsencrypt:/etc/letsencrypt db: container_name: db image: 'jc21/mariadb-aria:10.4' shm_size: '512MB' privileged: true restart: unless-stopped ports: - '3306:3306' networks: nginx_net: ipv4_address: 172.55.0.72 dns: - "1.1.1.1" - "1.1.0.0" ulimits: nproc: 65535 cap_add: - "CAP_SYS_RESOURCE" - "CAP_SYS_TIME" environment: MYSQL_ROOT_PASSWORD: '1234567890' MYSQL_DATABASE: 'nginx' MYSQL_USER: 'raw' MYSQL_PASSWORD: '123456789' volumes: - /NPM/data/mysql:/var/lib/mysql networks: nginx_net: driver: bridge driver_opts: com.docker.network.enable_ipv6: "false" ipam: driver: default config: - subnet: 172.55.0.0/16 ``` Now that we've set a static ip for each container and we have the mysql ip `172.55.0.72` config file will be ```js { "database": { "engine": "mysql", "host": "172.55.0.72", "name": "nginx", "user": "raw", "password": "123456789", "port": 3306 } } ``` ```bash root@server651029:~# docker-compose -f docker-compose.yml up -d Creating network "root_nginx_net" with driver "bridge" Creating nginx ... done Creating db ... done root@server651029:~# curl -s 'http://1.1.1.1:81/api/tokens' {"error":{"code":400,"message":"Internal Error"}} ```
kerem 2026-02-26 06:32:14 +03:00
Author
Owner

@theraw commented on GitHub (Apr 16, 2020):

You can close the issue after you read, since the project doesn't have anything wrong and mysql has been told that it's needed to be installed manually by us just wanted to share a full yml template.

<!-- gh-comment-id:614695837 --> @theraw commented on GitHub (Apr 16, 2020): You can close the issue after you read, since the project doesn't have anything wrong and mysql has been told that it's needed to be installed manually by us just wanted to share a full yml template.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#318
No description provided.