Nginx Proxy Manager (NPM) Installation and Usage Guide
A comprehensive guide to setting up Nginx Proxy Manager (NPM) on Docker. This guide covers installation with both Docker Compose and a single Docker CLI command, as well as a brief walkthrough on how to use NPM to manage hosts and automatically secure them with free Let's Encrypt SSL certificates.
Step 1: Brief Introduction to Nginx Proxy Manager
Nginx Proxy Manager, or NPM, is a user-friendly reverse proxy built on top of Nginx. It simplifies the complex task of managing your web services and handling SSL certificates by providing a simple, web-based interface. It eliminates the need to manually edit Nginx configuration files and automates the process of obtaining and renewing Let's Encrypt certificates for your domains.
Step 2: Installation with Docker Compose (Recommended)
Create a new file named `docker-compose.yml` and add the following content. This configuration sets up NPM and a dedicated MariaDB database to store its settings. It also maps the necessary ports: 80 (HTTP), 443 (HTTPS), and 81 (the web UI).
version: '3'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: always
ports:
- '80:80'
- '443:443'
- '81:81'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
db:
image: 'jc21/mariadb-aria:latest'
restart: always
environment:
- MYSQL_ROOT_PASSWORD=npm
- MYSQL_DATABASE=npm
- MYSQL_USER=npm
- MYSQL_PASSWORD=npm
volumes:
- ./data/mysql:/var/lib/mysql
Save the file, then run this command in the same directory to start the services.
docker-compose up -d
Step 3: Access the Web UI and Initial Setup
After the containers are running, navigate to the web UI by opening a browser and going to `http://your_server_ip:81`. The default credentials are `admin@example.com` and `changeme`. Log in and you will be prompted to change your email and password.
Step 4: Create a Proxy Host
Once logged in, go to `Proxy Hosts` in the dashboard and click `Add Proxy Host`. Enter the following information to direct traffic from a domain to a local service:
- **Domain Names:** Your domain (e.g., `app.yourdomain.com`).\n- **Scheme:** `http` or `https`.\n- **Forward Hostname / IP:** The local IP address or hostname of your service (e.g., `127.0.0.1` or `container-name`).\n- **Forward Port:** The port the service is running on (e.g., `3000`, `8080`).",
Step 5: Obtain Let's Encrypt SSL Certificate
To secure your host with HTTPS, click the **SSL** tab within the `Proxy Host` configuration. Select `Request a new SSL Certificate` and enter your email address. Make sure the 'Force SSL' option is checked. Click 'Save' and NPM will automatically obtain the certificate. Note: Your domain must be pointed to your server's IP address for this to work.
Step 6: Finalize and Test
Click `Save` to apply the changes. NPM will reload the Nginx configuration. You should now be able to access your service securely at `https://app.yourdomain.com`, with traffic being properly routed by NPM.
Step 7: Clean Up (Optional)
If you need to remove the NPM container and its data, you can use these commands. Be aware that this will permanently delete your NPM configuration and all managed hosts.
docker-compose down -v