NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22.6k stars 2.62k forks source link

Bad Gateway app login - serious issue #532

Closed mohdlatif closed 3 years ago

mohdlatif commented 4 years ago

Hi there, I have spent countless hours trying to configure nginxproxymanager on my server. My server details: OS: Centos 7 Nginx Docker and docker compose latest version. I am using https://vpssim.com/.

I created a subdomain and in the public_html folder I created both files config.json and docker-compose.yml

The first issue i faced is port 443 is used to generate certificate and 80 is being used by Nginx, so i have to find a way to change the ports.

So I did a little configuration by changing the port like this

  **- '8080:80'
  - '81:81'
  - '8443:443'**

Great, it works and the port 3306 is running image

The issue after this is whenever i try to login it says Bad Gateway

image

I have read many threads about this issue,

Here is what I have done

Change "host": "db" to "host": "my server IP", - Does not work Change "host": "db" to "host": "subdomain.mywebsite.com", - Does not work Turned off Nginx via systemctl stop nginx.service and run on the defaults ports (port 443 and 80)- Does not work

Here is log file

2020/07/29 11:21:24 [error] 245#245: *1973 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:30 [error] 245#245: *1975 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:35 [error] 245#245: *1977 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:40 [error] 245#245: *1979 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:45 [error] 245#245: *1981 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:49 [error] 245#245: *1984 connect() failed (111: Connection refused) while connecting to upstream, client: 202.186.36.196, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "nprxy.mywebsite.com:81", referrer: "http://nprxy.mywebsite.com:81/" 2020/07/29 11:21:51 [error] 245#245: *1986 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:56 [error] 245#245: *1988 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:59 [error] 245#245: *1984 connect() failed (111: Connection refused) while connecting to upstream, client: 202.186.36.196, server: nginxproxymanager, request: "POST /api/tokens HTTP/1.1", upstream: "http://127.0.0.1:3000/tokens", host: "nprxy.mywebsite.com:81", referrer: "http://nprxy.mywebsite.com:81/login" 2020/07/29 11:22:01 [error] 245#245: *1991 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"

How i can solve this issue.

Thanks.

godsom commented 4 years ago

I got same issue after first run docker-compose from full guide. from from my point database cannot start I fixed by change docker-compose.yml from db: image: jc21/mariadb-aria:10.4 to db: image: mariadb:latest

iga566 commented 4 years ago

Hi there, I have spent countless hours trying to configure nginxproxymanager on my server. My server details: OS: Centos 7 Nginx Docker and docker compose latest version. I am using https://vpssim.com/.

I created a subdomain and in the public_html folder I created both files config.json and docker-compose.yml

The first issue i faced is port 443 is used to generate certificate and 80 is being used by Nginx, so i have to find a way to change the ports.

So I did a little configuration by changing the port like this

  **- '8080:80'
  - '81:81'
  - '8443:443'**

Great, it works and the port 3306 is running image

The issue after this is whenever i try to login it says Bad Gateway

image

I have read many threads about this issue,

Here is what I have done

Change "host": "db" to "host": "my server IP", - Does not work Change "host": "db" to "host": "subdomain.mywebsite.com", - Does not work Turned off Nginx via systemctl stop nginx.service and run on the defaults ports (port 443 and 80)- Does not work

Here is log file

2020/07/29 11:21:24 [error] 245#245: *1973 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:30 [error] 245#245: *1975 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:35 [error] 245#245: *1977 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:40 [error] 245#245: *1979 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:45 [error] 245#245: *1981 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:49 [error] 245#245: *1984 connect() failed (111: Connection refused) while connecting to upstream, client: 202.186.36.196, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "nprxy.mywebsite.com:81", referrer: "http://nprxy.mywebsite.com:81/" 2020/07/29 11:21:51 [error] 245#245: *1986 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:56 [error] 245#245: *1988 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:59 [error] 245#245: *1984 connect() failed (111: Connection refused) while connecting to upstream, client: 202.186.36.196, server: nginxproxymanager, request: "POST /api/tokens HTTP/1.1", upstream: "http://127.0.0.1:3000/tokens", host: "nprxy.mywebsite.com:81", referrer: "http://nprxy.mywebsite.com:81/login" 2020/07/29 11:22:01 [error] 245#245: *1991 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"

How i can solve this issue.

Thanks.

i have the same issue

codeagencybe commented 4 years ago

I got it working!

db_1 | 2020-09-19 12:31:16 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 0 pages than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!

All I did was delete the .ibdata1 file that shows 0kb And then re-deploy the whole setup. Now it generates a new clean .ibdata file that is around 12Mb size

pierow2k commented 4 years ago

I fixed by change docker-compose.yml from db: image: jc21/mariadb-aria:10.4 to db: image: mariadb:latest

Fixed the issue for me as well. Many thanks @godsom !

wimmme commented 3 years ago

For me on a RPI 3 running Hypriot

db:
image: mariadb:latest

does not work, but this does:

db:
image: yobasystems/alpine-mariadb:armhf
anselal commented 3 years ago

@wimmme did not work for me on my rpi2

mcarter960 commented 3 years ago

This worked for me also...running on a pi4. Thank you wimmme

creating config.json and editing docker-compose.yml db: image: yobasystems/alpine-mariadb:armhf

anselal commented 3 years ago

This works on my RPi2

version: "2"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: always
    ports:
      # Public HTTP Port:
      - '80:80'
      # Public HTTPS Port:
      - '443:443'
      # Admin Web Port:
      - '81:81'
    environment:
      # These are the settings to access your db
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db
  db:
    image: yobasystems/alpine-mariadb:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./data/mysql:/var/lib/mysql

the trick besides changing the image for the DB is to use version: "2"

cxdy commented 3 years ago

I'm running on Ubuntu 20.04 inside a virtual machine.

Docker version 20.10.3 docker-compose version 1.28.2

2021/02/17 01:36:08 [error] 261#261: *33 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"
2021/02/17 01:36:13 [error] 261#261: *35 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"
2021/02/17 01:36:17 [error] 261#261: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.4, server: nginxproxymanager, request: "POST /api/tokens HTTP/1.1", upstream: "http://127.0.0.1:3000/tokens", host: "10.0.0.7:81", referrer: "http://10.0.0.7:81/login"
2021/02/17 01:36:18 [error] 261#261: *38 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"
2021/02/17 01:36:24 [error] 261#261: *40 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"

Here is my config:

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    environment:
      DB_MYSQL_HOST: "localhost"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "nginx"
      DB_MYSQL_PASSWORD: ""
      DB_MYSQL_NAME: "nginx"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
  db:
    image: 'mariadb:latest'
    environment:
      MYSQL_ROOT_PASSWORD: ''
      MYSQL_DATABASE: 'nginx'
      MYSQL_USER: 'nginx'
      MYSQL_PASSWORD: ''
    volumes:
      - ./data/mysql:/var/lib/mysql

Firewall:

Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
81                         ALLOW       Anywhere
80                         ALLOW       Anywhere
443                        ALLOW       Anywhere
3000                       ALLOW       Anywhere

download

Any ideas?

jc21 commented 3 years ago

First rule of docker debugging:

docker logs name_of_npm_container
cxdy commented 3 years ago

@jc21 I resolved it by changing my MYSQL IP in the docker-compose.yml to the IP of the docker container. All is well now, thanks!

jc21 commented 3 years ago

In your example you can also set the database host name to db since it's in the same docker-compose file