How to Install Nginx Proxy Manager on a VPS with Docker: Reverse Proxy and Automatic SSL from the Web UI
A VPS that starts out running a single app has a way of turning into a list of addresses nobody can remember: http://203.0.113.10:3000 for one service, http://203.0.113.10:8080 for another, and so on. Every new service means another port number to memorize, another firewall rule, and another "not secure" warning in the browser because the connection is still plain HTTP. Editing Nginx configuration files by hand for each service works, but one typo can take down every site on that server at once.
Nginx Proxy Manager (NPM) moves that work into a web interface. You add a proxy host through a form, fill in the domain and the service behind it, tick the certificate option, and NPM takes care of the Nginx configuration and Let's Encrypt renewals. This guide installs NPM as a single Docker container on a VPS, creates a first proxy host with HTTPS, and locks the admin panel away from the public internet.
Before you start: what you need
- A VPS with Docker and Docker Compose v2 installed.
- A domain whose
Arecord already points at the VPS public IP, for exampleapp.example.com. Let's Encrypt can only issue a certificate when the domain genuinely resolves to your server. - Ports
80and443free and reachable from the internet. Port80is still required even if you only want HTTPS, because the Let's Encrypt HTTP-01 validation runs over port80. - A service already running on the VPS that you want to publish, for example a web app on port
3000. NPM does not replace your app; it becomes its front door. - Port
81free for the NPM admin panel.
Check Docker and Compose:
docker --version
docker compose versionExpected output: both commands print version numbers without errors.
Step 1: create the folder and Compose file
Create the NPM project folder:
mkdir -p ~/npm
cd ~/npmThen create a docker-compose.yml file with a text editor, for example nano docker-compose.yml, and fill it with this configuration. This is the project's official quick-setup configuration, with the timezone adjusted to Asia/Jakarta:
services:
app:
image: 'jc21/nginx-proxy-manager:2.16.0'
restart: unless-stopped
environment:
TZ: "Asia/Jakarta"
ports:
- '80:80'
- '81:81'
- '443:443'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencryptA brief explanation of the important parts: the image jc21/nginx-proxy-manager:2.16.0 is NPM's official image; port 80 serves HTTP and Let's Encrypt validation, port 443 serves HTTPS, and port 81 opens the admin panel; the volume ./data:/data holds all of NPM's settings, including the proxy host list and users; the volume ./letsencrypt:/etc/letsencrypt holds the issued certificates; and TZ sets the container timezone so logs and renewal timing are easy to read.
One security note before you start this file: the official configuration above exposes port 81 to every address. The admin panel should not face the internet. If you only reach the VPS over SSH, change the admin port line to:
- '127.0.0.1:81:81'With that mapping the panel only answers from the server itself, and you reach it through an SSH tunnel from your own machine:
ssh -L 8181:localhost:81 root@Your-VPS-IPThen open http://localhost:8181 in your local browser. It is slightly more effort, but the admin panel never gets touched by internet scanners.
Step 2: start NPM and open the admin panel
Start the stack in the background:
docker compose up -d
docker compose ps
docker compose logs -f appExpected output: the app container shows as running, and the logs show the backend process starting to serve. The first start can take around a minute because NPM runs its internal database migrations; do not worry if the admin panel does not answer on the very first try. Press Ctrl+C to leave the log view.
Open the admin panel at http://Your-VPS-IP:81, or http://localhost:8181 if you are using the SSH tunnel. On a fresh install, follow the initial setup screen to create your own admin account, using an email address you actually use. Expected output: the NPM dashboard opens with the Proxy Hosts, Redirection Hosts, Streams, Access Lists, and SSL Certificates menus.
The diagram above summarizes the flow: a visitor opens https://app.example.com, NPM accepts the connection on port 443, matches the domain to the proxy host you created, and forwards the request to the service behind it, while the Let's Encrypt certificate renews automatically before it expires.
Step 3: put NPM and your service on one shared Docker network
NPM needs to be able to "see" the service it forwards to. The cleanest way is to place NPM and the service on the same Docker network, then forward to the service's container name rather than to localhost. Keep in mind: from inside the NPM container, localhost means the NPM container itself, not the VPS host, so forwarding to localhost almost always ends in a 502.
Create one shared network:
docker network create proxy-netThen add that network to NPM's docker-compose.yml:
services:
app:
image: 'jc21/nginx-proxy-manager:2.16.0'
restart: unless-stopped
environment:
TZ: "Asia/Jakarta"
ports:
- '80:80'
- '127.0.0.1:81:81'
- '443:443'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
networks:
- proxy-net
networks:
proxy-net:
external: trueApply the change and connect your service container to the same network:
docker compose up -d
docker network connect proxy-net your-service-container-nameReplace your-service-container-name with your app container's name, for example my-app. Find it with docker ps if you do not remember it. Expected output: NPM and the service share the proxy-net network, and NPM can resolve the service container name to its internal address.
Step 4: create the first proxy host with an SSL certificate
In the NPM admin panel, open Proxy Hosts, click Add Proxy Host, and fill in the form:
- Domain Names: enter
app.example.com, the domain whoseArecord already points at your VPS. - Scheme: choose
http, because the hop between NPM and the service on the internal Docker network is usually plain HTTP; HTTPS encryption happens on the visitor side, between the browser and NPM. - Forward Hostname / IP: enter your service container name, for example
my-app. - Forward Port: enter the service's internal port, for example
3000. - Enable Block Common Exploits to block request patterns commonly used by attackers.
- Switch to the SSL tab, choose Request a new SSL Certificate, enable Force SSL so all HTTP traffic redirects to HTTPS, enable HTTP/2 Support, accept the Let's Encrypt terms, and save.
Expected output: NPM contacts Let's Encrypt, validates the domain over port 80, and the proxy host appears in the list with a padlock icon. This usually finishes in under a minute when DNS is pointing correctly.
Open https://app.example.com in a browser. Expected output: your app loads with an HTTPS padlock and no port number in the address. Check from the terminal if you like:
curl -I https://app.example.comExpected output: the first response line shows HTTP/2 200 or your app's own status code, not an NPM error.
As an extra guard for a service that has no login of its own, you can create an Access List under Access Lists: add one username and password, then attach that access list to the proxy host. Every visitor then has to pass HTTP basic auth before reaching the app. It is no substitute for a real application login, but it is enough to keep a private service away from casual visitors.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
The admin panel on port 81 will not open | The container has not finished starting, or port 81 is already taken | Wait about a minute, then check docker compose ps and docker compose logs app; if there is a port conflict, change the admin port mapping |
The proxy host shows 502 Bad Gateway | Wrong forward hostname or port, or the service is not on the same network as NPM | Confirm the container name and internal port, and make sure the service is connected to the proxy-net network |
| Certificate issuance fails | DNS does not point at the VPS yet, or port 80 is blocked by the firewall | Check the domain's A record and confirm port 80 is reachable from the internet, then retry from the SSL tab |
| Endless redirect loop | The app behind NPM also forces HTTPS, or another proxy layer sits in front of NPM | Turn off forced redirection on the app side, or temporarily disable Force SSL to test |
| The container keeps restarting | The ./data or ./letsencrypt folders cannot be written to | Check the project folder ownership and the container logs; do not run NPM as a different user without adjusting folder permissions |
| A proxy host change has no effect | The configuration was not saved, or the browser is serving a cached page | Save the proxy host again, then test with curl or a private browser window |
Updating NPM
Since all settings and certificates live in host volumes, updating means pulling the newest image and recreating the container:
cd ~/npm
docker compose pull
docker compose up -d
docker compose psExpected output: the container returns to running status, the proxy host list stays intact, and certificates remain valid. Before updating, back up these two folders, since they hold all of NPM's state:
cp -r ~/npm/data ~/npm/data.backup
cp -r ~/npm/letsencrypt ~/npm/letsencrypt.backupSummary
| Part | Value used |
|---|---|
| Image | jc21/nginx-proxy-manager:2.16.0 |
| Public ports | 80 (HTTP + Let's Encrypt validation), 443 (HTTPS) |
| Admin panel port | 81 (bind to 127.0.0.1 when possible) |
| Data volume | ./data:/data |
| Certificate volume | ./letsencrypt:/etc/letsencrypt |
| Shared network | proxy-net |
| Example forward | my-app:3000 |
| Certificates | Let's Encrypt, requested from the SSL tab, renewed automatically |
| Restart | unless-stopped |
Final checklist
- ☐ The NPM container shows as
runningindocker compose ps. - ☐ The admin panel opens and the admin account is created.
- ☐ Port
81is not exposed directly to the internet. - ☐ NPM and the service share the same Docker network.
- ☐ The first proxy host shows an HTTPS padlock at
https://app.example.com. - ☐
curl -Iagainst the domain returns the app's response, not an NPM error. - ☐ The
./dataand./letsencryptfolders are backed up before the next update.
Which service will you publish first through NPM, and does it already have its own login or does it still need an access list? Share it in the comments, since that answer decides whether you can stop at the proxy host or need one more layer of protection.
Read also: the Rnevio article "Satu VPS, Banyak Layanan: Nginx Reverse Proxy + HTTPS Let's Encrypt" covers the same job done manually with Nginx configuration files, while the paired guide in this batch is available at a Pangolin guide for a private reverse proxy with access control.


Diskusi
Ada pertanyaan atau pengalaman yang ingin dibagikan?
Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.
Tulis komentar