Running five sites on one VPS used to mean hand-editing Nginx server blocks for every new domain, fighting certbot for certificates, and reloading configs at midnight. Nginx Proxy Manager (NPM) replaces that workflow with a web panel: you point a domain at it, add a proxy host, and both the reverse proxy and the TLS certificate get configured for you. This guide walks through the nginx proxy manager docker setup step by step, from compose file to SSL to access lists.
How the Nginx Proxy Manager Docker Setup Works
NPM is a reverse proxy with a management UI. You run one Docker container on ports 80 and 443, and every incoming HTTP request gets routed to the right backend based on the hostname. Backend services can be other Docker containers, a WordPress install, or an app on another machine in your network. Unlike Traefik, which is driven by labels and config files, NPM is designed for people who would rather click through a form than write YAML for each site.
One thing to know before starting: NPM manages certificates for you, so each public domain needs a DNS A record pointing at your server’s IP before you request a certificate. Check your records first, because Let’s Encrypt will fail validation if the domain does not resolve to the box.
Prerequisites
- A VPS with Docker Engine and the Docker Compose plugin installed. If you are starting from a fresh machine, follow our Docker Compose install guide for Ubuntu 24.04 first.
- A DNS A record for every domain you want to host, all pointing at the VPS IP.
- Ports 80, 443, and 81 open in your firewall. Our UFW setup guide covers the basics, and ports 22 plus your custom SSH port should stay restricted to your IP.
NPM itself is light. The proxy plus a handful of small apps fits comfortably on a 2 GB VPS, though you will want more memory if you are stacking heavier services behind it.
Deploy Nginx Proxy Manager with Docker Compose
Create a directory and a compose file:
mkdir -p /opt/npm && cd /opt/npm
cat > docker-compose.yml << 'EOF'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- '80:80'
- '443:443'
- '81:81'
environment:
DB_MYSQL_HOST: "db"
DB_MYSQL_PORT: 3306
DB_MYSQL_USER: "npm"
DB_MYSQL_PASSWORD: "changeme-strong-password"
DB_MYSQL_NAME: "npm"
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
depends_on:
- db
db:
image: 'jc21/mariadb-aria:latest'
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: 'changeme-root-password'
MYSQL_DATABASE: 'npm'
MYSQL_USER: 'npm'
MYSQL_PASSWORD: 'changeme-strong-password'
volumes:
- ./mysql:/var/lib/mysql
EOF
docker compose up -d
Wait about 30 seconds for the database to initialize, then open http://your-server-ip:81. The default login is [email protected] with password changeme. NPM forces you to change both on first login. Do that before anything else, and consider restricting port 81 to your own IP in UFW after setup since the admin panel should never be public.
Add Proxy Hosts for Multiple Sites
This is the core workflow. In the NPM panel, go to Hosts > Proxy Hosts and click Add Proxy Host for each site:
- Domain Names: enter the domain, e.g.
site1.example.com. Add bothexample.comandwww.example.comon one host if you want both routed to the same backend. - Forward Hostname / IP: the backend target, e.g.
172.18.0.5or a container name likewordpressif both are on the same Docker network. You can attach NPM to a shared network and reference containers by name. - Forward Port: the backend’s port, e.g.
8080for a Node app or80for a container exposing plain HTTP. - Forward Scheme: use
httpfor backends on your private network; switch tohttpsonly if the backend itself terminates TLS. - Advanced toggles: enable Cache Assets for static-heavy sites, Block Common Exploits for internet-facing apps, and Websockets Support for anything using websockets (chat apps, game servers, some dashboards). This one is off by default and is the most common cause of “site loads but live updates break.”
Repeat for each domain and you are hosting multiple sites through a single IP. Each proxy host gets its own SSL settings, so a certificate problem on one domain never affects the others.
Set Up Automatic SSL with Built-in Let’s Encrypt
NPM requests and renews certificates itself, so you can drop certbot from your setup. On the Proxy Host form, open the SSL tab and select Request a new SSL Certificate. Tick Force SSL to redirect HTTP to HTTPS, enable HTTP/2 Support, and agree to the Let’s Encrypt terms. Save, and NPM validates the domain and installs the certificate.
For servers behind a firewall or a wildcard certificate (one cert for *.example.com), use the DNS Challenge option instead. You add a DNS API token from your provider under SSL Certificates > Add SSL Certificate, and NPM completes the challenge without any inbound HTTP traffic. This is the only way to get certificates when port 80 is blocked or the server is not directly reachable.
Certificates renew automatically at 60 days. NPM logs renewal attempts under the certificate entry, so check there first if a site ever shows an expired cert warning.
Lock It Down with Access Lists
Some backends should not be public at all: the NPM admin panel itself, a staging site, a database dashboard. NPM’s access lists add basic authentication or IP allowlisting in front of a proxy host.
Go to Access Lists > Add Access List. Add users with the Authorization tab, or allow specific IPs and CIDR ranges under Access (e.g. 203.0.113.45/32 for your office, or your VPN range). Tick Satisfy Any if you want either valid credentials or a trusted IP to grant access; leave it unticked if you want to require both. Then open the proxy host and attach the list under its Access List dropdown.
Even with access lists in place, keep the machine’s own firewall tight. Our post-install VPS checklist covers SSH hardening and automatic updates, which matter just as much as anything inside the panel.
Common Pitfalls
Certificate requests failing. Nine times out of ten the DNS A record is wrong or has not propagated. Query it from the server with dig +short site.example.com and confirm it returns your VPS IP before clicking save.
502 Bad Gateway on every site. The backend is unreachable. If the backend is another container, make sure NPM shares a Docker network with it, or use the container’s published host port with the server IP as the forward hostname. Pinging from inside the NPM container (docker compose exec app ping backend-name) settles this in seconds.
Websockets not working. Enable Websockets Support on the proxy host. Symptoms are apps that load fine but never receive live updates.
Mixed content warnings. The backend thinks it is served over plain HTTP and generates http:// URLs for assets. In the proxy host’s Advanced tab, add a custom location that sets the X-Forwarded-Proto header, or configure the backend app to trust the proxy’s forwarded headers.
Admin panel exposed. Port 81 is the management UI. Close it to the internet with UFW after your initial setup, or at minimum keep a strong password and access list on it.
Keep It Updated and Healthy
Update the stack with the standard Compose flow: docker compose pull && docker compose up -d. The volumes hold the database and certificates, so the data survives image updates. Back up /opt/npm on a schedule; without those volumes, a disk failure means re-creating every proxy host by hand.
Watch resource usage as you add sites. Check memory and disk with htop, df, and free occasionally, especially after adding caching backends that eat RAM. A single NPM instance comfortably fronts dozens of low-traffic sites on a small VPS, which is exactly why this setup is popular for agencies and side-project stacks.