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/letsencryptEnable port 81 in firewall (needed when network_mode: host).
sudo ufw allow port 81Generate a self signed certificate.
openssl req -newkey rsa:4096 \
-x509 \
-sha256 \
-days 3650 \
-nodes \
-out myserver.mydomain.crt \
-keyout myserver.mydomain.keyCountry 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 -dAccess 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 XAccess use https://npm.myserver.mydomain