How to Deploy and Use Nginx Proxy Manager with Docker for Static and Dynamic Proxying
This guide explains how to install Nginx Proxy Manager via Docker, configure static and dynamic proxy hosts, set up SSL, and manage users, providing a hands‑on example using a mall e‑commerce project.
Overview
Nginx Proxy Manager (NPM) provides a web UI for managing Nginx reverse proxies, SSL certificates, access control, and user permissions without editing Nginx configuration files directly.
Installation
Run the official Docker image:
docker pull jc21/nginx-proxy-manager:latest docker run -p 80:80 -p 81:81 -p 443:443 \
--name nginx-proxy-manager \
-v /mydata/nginx-pm/data:/data \
-v /mydata/nginx-pm/letsencrypt:/etc/letsencrypt \
-d jc21/nginx-proxy-manager:latestAfter the container starts, open http://<em>host</em>:81. Default credentials are [email protected]:changeme.
Static proxy configuration
Example: serve two static sites (admin UI and shop front‑end) under the same domain.
Add host entries on the client machine: 192.168.3.101 mall.macrozheng.com Create a proxy host in NPM with domain mall.macrozheng.com and target http://192.168.3.101.
In the Advanced tab, add custom location blocks:
location /admin {
alias /data/html/admin;
index index.html index.htm;
}
location /app {
alias /data/html/app;
index index.html index.htm;
}Upload the built static files to the container paths /mydata/nginx-pm/data/html/admin and /mydata/nginx-pm/data/html/app.
Resulting URLs:
Admin UI – http://mall.macrozheng.com/admin/ Shop front‑end –
http://mall.macrozheng.com/app/Dynamic proxy configuration
Example: expose a backend API service.
Add a host entry: 192.168.3.101 api.macrozheng.com Create a new proxy host with hostname admin-api.macrozheng.com (or api.macrozheng.com) and point it to the API container’s address.
The API Swagger UI becomes reachable at http://api.macrozheng.com/swagger-ui/.
Additional features
Enable SSL with automatic Let’s Encrypt certificate issuance and renewal.
Configure Access Lists for Basic authentication on individual proxy hosts.
Manage users, roles, and permissions via the built‑in User Management.
Audit Log records administrative actions.
Chinese localized image
A community‑maintained Chinese UI image is available. Run it with the same volume mounts:
docker run -p 80:80 -p 81:81 -p 443:443 \
--name nginx-proxy-manager \
-v /mydata/nginx-pm/data:/data \
-v /mydata/nginx-pm/letsencrypt:/etc/letsencrypt \
-d chishin/nginx-proxy-manager-zh:releaseReference repository
Official source code:
https://github.com/NginxProxyManager/nginx-proxy-managerSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
