Setting up Nginx Proxy Manager with Docker Compose
What we'll do:
- Install docker
- Setup Nginx Proxy Manager
This guide is aimed at Ubuntu/Debian systems.
Why:
To run multiple services over the same port a reverse proxy service is required. Nginx Proxy Manager is a WebUI frontend for the popular Nginx Reverse Proxy.
To get a good understanding of how a reverse proxy works, it would be worth setting up Nginx without the WebUI.
As Nginx Proxy Manager is running within a docker container you will get slower speeds compared to running Nginx on the host.
Install
- Update Linux
sudo apt update && sudo apt upgrade
- Install docker
Ubuntu: https://docs.docker.com/engine/install/ubuntu/
Debian: https://docs.docker.com/engine/install/debian/
- Install docker-compose
sudo apt install docker-compose
- Create docker network
This will allow us to set static IP's for the docker containers.
sudo docker network create --driver=bridge --subnet=10.10.10.0/24 --gateway=10.10.10.1 dockernet
- Create directorys to store the volumes within.
cd
- Go to home dir
sudo mkdir nginxmanager
cd nginxmanager
sudo mkdir data
sudo mkdir letsencrypt
sudo mkdir sql
- Create docker-compose.yaml file
sudo nano docker-compose.yaml
Use the following template:
version: "3"
services:
app:
image: jc21/nginx-proxy-manager:2
restart: always
ports:
# Public HTTP Port:
- '80:80'
# Public HTTPS Port:
- '443:443'
# Admin Web Port:
- '81:81'
networks:
default:
ipv4_address: 10.10.10.3
volumes:
- /home/USER/nginxmanager/config.json:/app/config/production.json
- app-data:/data
- app-letsencrypt:/etc/letsencrypt
depends_on:
- db
db:
image: jc21/mariadb-aria:10.4
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'npm'
MYSQL_DATABASE: 'npm'
MYSQL_USER: 'npm'
MYSQL_PASSWORD: 'npm'
networks:
default:
ipv4_address: 10.10.10.2
volumes:
- app-sql:/var/lib/mysql
volumes:
app-data:
driver_opts:
type: none
device: /home/USER/nginxmanager/data
o: bind
app-letsencrypt:
driver_opts:
type: none
device: /home/USER/nginxmanager/letsencrypt
o: bind
app-sql:
driver_opts:
type: none
device: /home/USER/nginxmanager/sql
o: bind
networks:
default:
external:
name: dockernet
Replace "USER" with your username (there are 4).
- Create config.json
sudo nano config.json
Use the following template:
{
"database": {
"engine": "mysql",
"host": "db",
"name": "npm",
"user": "npm",
"password": "npm",
"port": 3306
}
}
- Start the docker container
sudo docker-compose up -d
- Access the WebUI
Head to http://SERVER-IP:81
Default login:
Email: [email protected]
Password: changeme
Sources:
https://nginxproxymanager.com/
https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/