Automate SSL and Reverse Proxies with Nginx Proxy Manager: A Docker-Compose Walkthrough
NginxProxyManager/nginx-proxy-manager
Nginx Proxy Manager is a powerful tool built on Nginx that drastically simplifies the management of reverse proxies. From a software engineer's perspective, this means
Speed & Efficiency
You can set up a new reverse proxy in minutes via a clean web interface, rather than manually writing and debugging complex Nginx configuration files (.conf files). This is a huge time-saver, especially for deploying internal tools, staging environments, or self-hosted applications.
Built-in SSL/TLS
NPM integrates seamlessly with Let's Encrypt to provide free SSL certificates automatically. It handles the entire lifecycle—generation, deployment, and automatic renewal—all through the GUI. This eliminates the headache of manual certificate management.
Docker-First Approach
Because it's a Docker container, deployment is incredibly easy and isolated from your host system. It fits perfectly into modern, containerized workflows, making it a great addition to your docker-compose.yml file.
Centralized Management
It provides a single, beautiful dashboard to manage all your proxy hosts, redirections, and streams. This is much cleaner than scattering Nginx config files across multiple servers or relying solely on the command line.
In short, NPM lets you focus on writing and shipping code instead of being bogged down in the intricacies of Nginx configuration and SSL management.
The most recommended way to introduce NPM is using Docker Compose. This allows you to define the NPM container and its required database in a single, version-controlled file.
A server (or local machine) with Docker and Docker Compose installed.
Ports 80 (HTTP), 443 (HTTPS), and 81 (NPM Admin Interface) must be free and accessible (and potentially port-forwarded on your router if self-hosting).
A domain name pointed to your server's IP address (A-Record) for the SSL functionality to work.
Here is a basic example you can use to spin up NPM
version: '3.8'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
container_name: nginxproxymanager
restart: unless-stopped
ports:
# These ports are for the public internet to reach your proxied services
- '80:80' # Public HTTP
- '443:443' # Public HTTPS
# This port is for accessing the Nginx Proxy Manager Web UI
- '81:81' # Admin Panel
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
environment:
# Database configuration (adjust as needed, using SQLite by default is also possible)
DB_SQLITE_FILE: /data/database.sqlite
# If using a separate MySQL/MariaDB container, you would configure it here:
# DB_MYSQL_HOST: "db"
# DB_MYSQL_PORT: 3306
# DB_MYSQL_USER: "npm"
# DB_MYSQL_PASSWORD: "npm"
# DB_MYSQL_NAME: "npm"
# Optional: You can also include a separate database service, like MariaDB
# db:
# image: 'mariadb:latest'
# container_name: mariadb
# restart: unless-stopped
# environment:
# MYSQL_ROOT_PASSWORD: 'changeme_root_password'
# MYSQL_DATABASE: 'npm'
# MYSQL_USER: 'npm'
# MYSQL_PASSWORD: 'npm'
# volumes:
# - ./mysql:/var/lib/mysql
Save the file
Save the code above as docker-compose.yml in a new directory (e.g., ~/npm/).
Run the container
Open your terminal in that directory and run
docker compose up -d
Access the Admin Interface
Once the container is running, open your web browser and navigate to http://<your-server-ip>:81.
Initial Login
Email
[email protected]
Password
changeme
Crucial
Change the default credentials immediately upon logging in!
Once logged into the web UI (on port 81), setting up a proxy for a service running on the same network is straightforward.
Let's say you have an application running in another Docker container on your server at internal port 3000 (e.g., a Node.js app) and you want it accessible via the domain myapp.yourdomain.com.
Go to Hosts -> Proxy Hosts.
Click Add Proxy Host.
Details Tab
Domain Names
myapp.yourdomain.com
Scheme
http (since the internal connection is often plain HTTP)
Forward Hostname/IP
The container name (if in the same Docker network) or the internal IP of the service (e.g., 172.17.0.x or myapp-container-name).
Forward Port
3000
Block Common Exploits
Check this box for security.
SSL Tab
SSL Certificate
Select <Request a new SSL Certificate>
Force SSL
Check this box to redirect all HTTP traffic to HTTPS.
I Agree to the Let's Encrypt Terms of Service
Check this box.
Email Address
Enter your real email address for important certificate notifications.
Click Save.
NPM will now communicate with Let's Encrypt, issue your SSL certificate, and configure the Nginx reverse proxy. Your application will be immediately accessible and secured at https://myapp.yourdomain.com/!
This video explains a detailed process for installing and configuring Nginx Proxy Manager using Docker Compose
Install & Configure Nginx Proxy Manager in 10-Minutes - An Easy Step-By-Step Guide.