mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
504 words
3 minutes
Deploying Nginx Proxy Manager with Docker: Reverse Proxy Made Easy for Beginners
2025-02-20

If you’ve ever set up your own Home Lab or VPS services, you must have run into this problem: I have multiple services (Portainer, Halo, Alist) running on different ports (9000, 8090, 5244), but I want to access them using different subdomains of a single domain (like demo.com), and I want all of them to have the HTTPS green padlock.

Hand-writing Nginx configuration files (nginx.conf) is not only error-prone but also makes applying for and renewing SSL certificates extremely troublesome.

Today I recommend an amazing tool: Nginx Proxy Manager (NPM). It allows you to get all of this done in minutes via a graphical interface.

1. Why Choose Nginx Proxy Manager?#

  • Visual UI: All configurations are done by clicking around in a web browser.
  • Automatic SSL: Built-in Let’s Encrypt support; one-click application and automatic renewal of certificates.
  • Docker Deployment: Doesn’t pollute the host environment and can be migrated at any time.

Architecture Diagram#

User (Browser)
[ Nginx Proxy Manager (Port 80/443) ] ────► [ Automatic SSL Management ]
├───► demo.com ────► [ Portainer (Port 9000) ]
├───► blog.demo.com ────► [ Halo Blog (Port 8090) ]
└───► pan.demo.com ────► [ Alist (Port 5244) ]

2. Docker Compose Deployment#

First, ensure your server has Docker and Docker Compose installed. Create a folder and create a new docker-compose.yml:

version: '3'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- '80:80' # HTTP Traffic
- '81:81' # Admin Panel Entry
- '443:443' # HTTPS Traffic
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt

Start the service:

docker-compose up -d

3. Initial Configuration#

  1. Access http://<Your Server IP>:81.
  2. Default login credentials: admin@example.com, password: changeme.
  3. Be sure to change your email and password immediately after your first login.

4. In Practice: Forwarding the Portainer Panel#

Assume your Portainer is running at http://127.0.0.1:9000, and you want to access it via portainer.yourdomain.com.

  1. Add Proxy Host: Click “Proxy Hosts” -> “Add Proxy Host” on the Dashboard.
  2. Details Tab:
    • Domain Names: portainer.yourdomain.com
    • Scheme: http
    • Forward Hostname / IP: 172.17.0.1 (This is the Docker bridge’s host IP, or use the public IP)
    • Forward Port: 9000
    • Check Block Common Exploits (Basic protection).
  3. SSL Tab:
    • SSL Certificate: Select “Request a new SSL Certificate”.
    • Check Force SSL.
    • Enter your Email and agree to the terms.
  4. Save: Click Save. Wait a few seconds, NPM will automatically verify the domain and request the certificate.

Done! Now you can access your panel via a secure HTTPS link.

Common Pitfalls and Troubleshooting#

  1. SSL Application Failed (Internal Error)

    • Check Ports: You must ensure that your server firewall’s 80 and 443 ports are open to the public.
    • DNS Resolution: Ensure your domain has correctly resolved to the server IP and has taken effect (can be checked using ping).
    • Email Not Provided: When applying for a certificate, although the Email field is optional, it is recommended to fill it in; otherwise, Let’s Encrypt might reject the request.
  2. 502 Bad Gateway

    • Incorrect IP Entry: In Forward Hostname, never enter 127.0.0.1 (unless NPM’s network mode is set to host).
    • Correct Approach: Enter the Docker container’s LAN IP or the host machine’s internal IP (e.g., 172.17.0.1).
  3. File Upload Limits

    • The default Nginx configuration limits upload sizes. If you encounter failures uploading large files, you need to add this under the Proxy Host config -> Advanced in NPM:
      client_max_body_size 0;

5. Summary#

Nginx Proxy Manager significantly lowers the barrier to entry for reverse proxying. For individual developers and home lab users, it perfectly balances ease of use and functionality, making it an essential piece of infrastructure.

Share

If this article helped you, please share it with others!

Deploying Nginx Proxy Manager with Docker: Reverse Proxy Made Easy for Beginners
https://blog.levifree.com/posts/nginx-proxy-manager/
Author
LeviFREE
Published at
2025-02-20
License
CC BY-NC-SA 4.0

Some information may be outdated

Table of Contents