NginxProxyManager + Docker Setup Guide
fekie July 25, 2024 #docker #setup #guideThis guide will show you how to set up NginxProxyManager with containerized web apps. This was a very painful process to set up so I decided to write a guide about it.
Prerequisites
- Docker + Docker Compose Plugin
- Have Nginx uninstalled
- Ports 80, 443, and 81 are open on your server
- An
A
DNS record pointing to the server's IP address
Setup
Setting up the NginxProxyManager container
- Create and clone a Github repository for your
NginxProxyManager
configs and data. - Create a
docker_compose.yml
and paste the following. The<NETWORK>
value can be any alphanumeric value, as long as it is the same network that our services will be running on. Port 81 is how we will access the admin panel for NginxProxyManager.
version: "3.8"
services:
app:
image: "jc21/nginx-proxy-manager:latest"
restart: unless-stopped
container_name: nginxproxymanager
ports:
# These ports are in format <host-port>:<container-port>
- "80:80" # Public HTTP Port
- "443:443" # Public HTTPS Port
- "81:81" # Admin Web Port
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
networks:
default:
external: true
name: <NETWORK>
- Start the program with
Logging into the admin portal
- Head to the newly created admin portal by heading to
<SERVER_ADDRESS>:81
- Log in using the default email and password (which is currently
admin@email.com
andchangeme
respectively) - Immediately after logging in, change the password (I believe the button shows if you click the profile button at the top right) and create the account with an email and save the login info.
Configuring projects to be proxied by NginxProxyManager
- We need the child project to have the same
<NETWORK>
as ourNginxProxyManager
docker instance. We also need to make sure that our child project has a container name. An exampledocker-compose.yml
for a project is:
services:
<PROJECT_NAME>:
build: .
command: npm run start
ports:
- "127.0.0.1:<HOST_PORT>:<DOCKER_PORT>"
container_name: <PROJECT_NAME>
networks:
default:
external: true
name: <NETWORK>
- Go ahead and start the docker container with:
- Just to note, containers can be stopped with the following:
Setting up reverse proxies
- On the dashboard, click on
Proxy Hosts
->Add Proxy Host
- On the details tab, enter the info as follows:
Domain Names: <DOMAIN> // -> Click on add domain
Scheme: http
Forward Hostname/IP: <PROJECT_NAME> // (this will be the container_name in our docker compose file from earlier)
Forward Port: <HOST_PORT>
Block Common Exploits: True
- On the ssl tab, enter the info as follows:
SSL Certificate: Request a new SSL Certificate
Force SSL: true
Email Address for Let's Encrypt: <EMAIL> // -> agree to terms of service
- Your site should now be available at
<DOMAIN>