Building a Top-Notch Nginx Proxy Manager (NPM) Implementation on Ubuntu 22.04 with Docker

Ashish Singh
Dev Genius
Published in
2 min readApr 16, 2024

--

In modern web development and server management, efficiently routing incoming requests to the appropriate backend services is crucial. Nginx Proxy Manager provides a user-friendly interface to manage Nginx reverse proxy configurations, making it easier to handle complex routing setups. Leveraging Docker simplifies the deployment process, ensuring consistency and portability across different environments. In this guide, we’ll walk through setting up Nginx Proxy Manager on Ubuntu 22.04 using Docker, step by step.

Prerequisites:

Before we begin, ensure you have the following prerequisites:

  1. Ubuntu 22.04 Server installed.
  2. Docker installed on your Ubuntu server.
  3. Docker Compose installed for managing multi-container Docker applications.

Step 1: Install Docker and Docker Compose:

$ sudo apt update

$ sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

$ sudo apt update

$ sudo apt install -y docker-ce docker-ce-cli containerd.io

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

$ sudo chmod +x /usr/local/bin/docker-compose

Step 2: Create Docker Compose File:

Create a directory for your Nginx Proxy Manager setup and navigate into it:

$ mkdir nginx-proxy-manager

$ cd nginx-proxy-manager

Create a docker-compose.yml file:

version: '3'

services:
app:
image: jc21/nginx-proxy-manager:latest
ports:
- "80:80"
- "443:443"
- "81:81"
environment:
DB_MYSQL_HOST: "db"
DB_MYSQL_PORT: 3306
DB_MYSQL_USER: "npm"
DB_MYSQL_PASSWORD: "npm"
DB_MYSQL_NAME: "npm"
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
- ./nginx:/etc/nginx
restart: always

db:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: "npm"
MYSQL_DATABASE: "npm"
MYSQL_USER: "npm"
MYSQL_PASSWORD: "npm"
volumes:
- ./data/mysql:/var/lib/mysql
restart: always

Step 3: Create Directories:

$ mkdir data

$ mkdir data/mysql

$ mkdir letsencrypt

$ mkdir nginx

Step 4: Start Nginx Proxy Manager:

$ docker-compose up -d

Step 5: Access Nginx Proxy Manager:

Once the containers are up and running, access the Nginx Proxy Manager web interface by navigating to http://your_server_ip:81. Follow the on-screen instructions to set up your proxy hosts and configurations.

Conclusion:

By following these steps, you’ve successfully set up Nginx Proxy Manager on Ubuntu 22.04 using Docker. This setup provides a robust and user-friendly solution for managing reverse proxy configurations, allowing you to efficiently route traffic to your backend services. With Docker, the deployment process becomes streamlined and consistent, ensuring seamless operation across different environments.

--

--