NginxProxyManager / nginx-proxy-manager

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

Got an error reading communication packets #2838

Open radaniba opened 1 year ago

radaniba commented 1 year ago

Hi everyone I am using npm deployed through a portainer stack. Everything worked fine until I had to upgrade my server for more resources. On stack restarts, i lost connection to npm and it didn't want to start over. I rebuilt the stack hoping to still have access to my data. The stack went up, docker images started fine, but when I login to my admin I have the "bad gateway" error message in the login screen I checked the logs for the db and I have these messages

2023-04-18  3:44:48 5 [Warning] Aborted connection 5 to db: 'npm' user: 'npm' host: '172.21.0.3' (Got an error reading communication packets)

my docker compose is classic

version: "3.3"
services:
  npm-app:
    image: 'jc21/nginx-proxy-manager:2.9.18'
    container_name: npm-app
    restart: unless-stopped
    ports:
      - '8081:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      DB_MYSQL_HOST: "npm-db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: ${DB_MYSQL_PASSWORD}
      DB_MYSQL_NAME: "npm"
      LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
      # Uncomment the line below if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./npm-data:/data:Z
      - ./letsencrypt:/etc/letsencrypt:Z
    depends_on:
      - npm-db
    networks:
      - npm-network
      - npm-internal

  npm-db:
    image: 'mariadb:latest'
    container_name: npm-db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: ${DB_MYSQL_PASSWORD}
    volumes:
      - ./npm-data/mysql:/var/lib/mysql:Z
    networks:
      - npm-internal

networks:
  npm-internal:
  npm-network:
    external: true

I am thinking maybe because of the restart, something went wrong with the db .

On the app side log I have some permission denied errors

[4/18/2023] [3:52:35 AM] [Global   ] › ✖  error     create table `migrations` (`id` int unsigned not null auto_increment primary key, `name` varchar(255), `batch` int, `migration_time` timestamp) - ER_CANT_CREATE_TABLE: Can't create table `npm`.`migrations` (errno: 13 "Permission denied")

Any idea on how to save my admin session without losing data ?

Thanks

radaniba commented 1 year ago

I investigated a bit further and managed to make it work by separating the folders for app and database in the volumes, so to realize that it is a new fresh mysql container that I have and it is not pointing to my old data.

I tried naively to copy the mysql folder on my host to the new mount point but I got this error

2023-04-18  5:41:08 185 [Warning] Access denied for user 'npm'@'172.25.0.3' (using password: YES)

I think the host changed from 172.25.0.3 to 172.25.0.2 and somehow it is still stored in the database tables (which ones I am not sure) so I have issues in the connections.

Do you guys have any ideas how I can safely restore my data stored in /data/compose/1/npm-data/mysql/ ?

radaniba commented 1 year ago

Ok some updates on this in case you need similar solutions. I was able to restore my data and proxies by following recommendation on other issues, and by changing permission level on the db image to mysql

This gave me access to all my proxies.

The problem that remains now is that I am not able to create new proxies anymore, especially when I ask for SSL certicates, I got internal problem issue that I am investigating now, any help would be welcome

[Express  ] › ⚠  warning   Command failed: certbot certonly --config "/etc/letsencrypt.ini" --cert-name "npm-21" --agree-tos --authenticator webroot --email "xxx@xxx.com" --preferred-challenges "dns,http" --domains "domain.name.masked"
github-actions[bot] commented 6 months ago

Issue is now considered stale. If you want to keep it open, please comment :+1: