Install Nginx Proxy Manager (NPM) with Docker

Install Nginx Proxy Manager (NPM) with Docker

Nginx is a popular server and reverse proxy used to route and redirect the web traffic . Setting up Nginx as a reverse proxy can be time-consuming and prone to errors and mis-configurations .

The Nginx proxy manager (NPM) is a reverse proxy management system running on Docker. NPM is based on an Nginx server and provides users with a clean, efficient, and beautiful web interface for easier management. The tool is easy to set up and does not require users to know how to work with Nginx servers or SSL certificates. NPM is an open-source tool maintained by developers from around the world. It is well suited for small server environments and private lab environments. This tutorial will focus on showing you how to deploy the Nginx proxy manager:

Here I'm trying to explain how to install Nginx Proxy Manager with help of Docker and Docker-Compose.

What you need to before we start:

  1. A linux server installed with Docker and Docker-Compose
  2. Root Permission (Sudo Permisssion)

If you need any help on how to install Docker and Docker-Compose, you may refer the official documentation.

Get Docker
Home page for Get Docker
Overview
Introduction and Overview of Compose

Once you set up these, let's begin.

Create the directory and necessary files

mkdir proxy
cd proxy
nano docker-compose.yml

You can copy paste below code for docker-compose.yml

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    container_name: proxy-manager
    restart: unless-stopped
    ports:
      - '80:80' 
      - '81:81'
      - '443:443'
    volumes:
      - ./config.json:/app/config/production.json
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - proxydb
    networks:
      - nginx-proxy

  proxydb:
    image: 'yobasystems/alpine-mariadb:latest'
    container_name: proxy-manager-db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'somestrongrootpassword'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'user-from-config.json'
      MYSQL_PASSWORD: 'password-from=config.json'
    volumes:
      - ./data/mysql:/var/lib/mysql
    networks:
      - nginx-proxy

volumes:
  mysql:
  data:
  letsencrypt:

networks:
  nginx-proxy:
    external:
      name: nginx-proxy-network

Create another file called config.json in same directory

nano config.json

Copy below content to the file.

{
  "database": {
    "engine": "mysql",
    "host": "proxy-manager-db",
    "name": "npm",
    "user": "someusername",
    "password": "somestrongpassword",
    "port": 3306
  }
}

We have almost done with the configuration, now we need to execute below command to bring the dockers active

docker-compose up -d

Log in with the default administrator user

navigate to http://"Server-IP":81 to access the proxy. login with below default username and password.

Email: [email protected]
Password: changeme

Now you have fully functional Nginx Proxy Manager ;)