Skip to content

Instantly share code, notes, and snippets.

@brccabral
Last active March 1, 2026 01:35
Show Gist options
  • Select an option

  • Save brccabral/1e202750ef7c543893394c0de608c2a4 to your computer and use it in GitHub Desktop.

Select an option

Save brccabral/1e202750ef7c543893394c0de608c2a4 to your computer and use it in GitHub Desktop.
Nginx Proxy Manager using Docker

Nginx Proxy Manager using Docker

We need NPM to run in network host so it can make use of 127.0.0.1 when setting new hosts, otherwise it will be considered NPM container itself, not the server.

services:
  app:
    container_name: nginxproxymanager
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    network_mode: host
    environment:
      TZ: "America/Los_Angeles"
    # ports are ignored when using `network_mode: host`
    #ports:
    #  - '80:80'
    #  - '81:81'
    #  - '443:443'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt

Enable port 81 in firewall (needed when network_mode: host).

sudo ufw allow port 81

Generate a self signed certificate.

openssl req -newkey rsa:4096 \
            -x509 \
            -sha256 \
            -days 3650 \
            -nodes \
            -out myserver.mydomain.crt \
            -keyout myserver.mydomain.key
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:California
Locality Name (eg, city) []:Los Angeles
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:myserver.mydomain
Email Address []:

Start NPM

docker compose up -d

Access admin page http://myserver.mydomain:81.
Add the custom certificate.
Add a new host. Suggest to add one for the admin page so it uses the certificate and not plain http.

npm.myserver.mydomain
http 127.0.0.1 81
Select the certificate in SSL tab

Make sure npm.myserver.mydomain is in your DNS server (ie Pihole).
Remove the port 81 from the firewall.

sudo ufw status numbered
sudo ufw delete X

Access use https://npm.myserver.mydomain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment