Files
truenas-app-to-docker/ep-npm-docker/README.md
T

4.4 KiB

Nginx Proxy Manager Docker Setup

Docker environment for running Nginx Proxy Manager restored from TrueNAS backup.

Quick Start

SQLite (Default - Simpler)

# 1. Copy environment template
cp .env.example .env

# 2. Start with SQLite profile
docker-compose --profile sqlite up -d

# 3. Access admin UI at http://localhost:81
# Default login: admin@example.com / changeme (CHANGE IMMEDIATELY!)

MariaDB (Production)

# 1. Copy and edit environment
cp .env.example .env
nano .env
# Set: DB_TYPE=mariadb, DB_ROOT_PASS=xxx, DB_PASS=yyy

# 2. Start with MariaDB profile
docker-compose --profile mariadb up -d

# 3. Access admin UI at http://localhost:81

Directory Structure

ep-npm-docker/
├── Dockerfile               # Based on jc21/nginx-proxy-manager:latest
├── docker-entrypoint.sh     # Handles permissions, DB wait
├── docker-compose.yml       # SQLite OR MariaDB profiles
├── .env.example             # Environment template
└── npm-data/                # Your data (create this)
    ├── data/                # Config, SSL certs, SQLite DB
    └── letsencrypt/         # Let's Encrypt certificates

Restore from Backup

After running the restore script on the Docker host:

# Symlink or copy to ./npm-data
ln -s ../npm-data ./npm-data
# OR
cp -r ../npm-data/* ./npm-data/

# Start appropriate profile
docker-compose --profile sqlite up -d
# OR
docker-compose --profile mariadb up -d

Environment Variables

Variable Description Default
DB_TYPE Database type: sqlite or mariadb sqlite
DB_ROOT_PASS MariaDB root password required for MariaDB
DB_NAME Database name npm
DB_USER Database user npm
DB_PASS Database user password required for MariaDB
NPM_DATA_DIR Host data directory ./npm-data
HTTP_PORT HTTP port 80
ADMIN_PORT Admin UI port 81
HTTPS_PORT HTTPS port 443

Profiles

  • sqlite (default): No separate DB container, uses SQLite file in data/database.sqlite
  • mariadb: Uses MariaDB 10.11 container, better for high-traffic setups
# SQLite
docker-compose --profile sqlite up -d

# MariaDB
docker-compose --profile mariadb up -d

Default Login

After first startup:

  • Email: admin@example.com
  • Password: changeme

CHANGE IMMEDIATELY! Go to Settings → Users → Edit admin user.

Post-Restore Steps

  1. Verify Proxy Hosts - Check Hosts → Proxy Hosts
  2. Update Forward IPs - If Docker network changed, update forward hostnames/IPs
  3. Test SSL Certificates - Check SSL Certificates tab, force renewal if needed
  4. Verify Access Lists - Check Access Lists tab

Custom Entrypoint Features

The custom docker-entrypoint.sh:

  • Fixes permissions on data/ and letsencrypt/ directories
  • Waits for MariaDB if using MariaDB profile

Ports

Port Purpose
80 HTTP traffic
81 Admin Web UI
443 HTTPS traffic

Logs

# View NPM logs
docker-compose logs -f npm

# View DB logs (MariaDB only)
docker-compose logs -f db

Backup (Docker-side)

# SQLite - backup database file
cp npm-data/data/database.sqlite backup_db_$(date +%Y%m%d).sqlite

# MariaDB
docker-compose exec db mariadb-dump -u root -p"$DB_ROOT_PASS" npm > backup_$(date +%Y%m%d).sql

# Files (both)
tar -czf npm_files_$(date +%Y%m%d).tar.gz npm-data/

Stopping

docker-compose --profile sqlite down
# OR
docker-compose --profile mariadb down

Security Notes

  1. Change default admin password immediately!
  2. Use strong passwords in .env for MariaDB
  3. Restrict admin UI access - put behind VPN or allowlist IPs
  4. Use HTTPS - NPM manages Let's Encrypt certs automatically
  5. Regular backups - Both database and letsencrypt certificates

Troubleshooting

502 Bad Gateway

  • Check upstream service is running
  • Use Docker service names instead of IPs (e.g., nextcloud instead of 172.17.0.x)
  • Verify proxy host configuration

SSL Certificate Errors

  • Check certificates exist in npm-data/letsencrypt/live/
  • Force renewal in NPM UI: SSL Certificates → Force Renewal
  • Check Let's Encrypt rate limits

Admin UI Not Accessible

  • Check container running: docker-compose ps
  • Check logs: docker-compose logs npm
  • Verify port 81 not blocked by firewall