How to Install and Use Nginx Proxy Manager with Docker

How to Run the Nginx Proxy Manager

The Nginx Proxy Manager provides access to a dashboard for managing proxy services. The setup is relatively straightforward. Once the Nginx Proxy Manager is running, everything else is covered within the manager’s web interface.

Follow along to get an Nginx Proxy Manager instance up and running.

Installing Docker and Docker Compose

Docker Compose is the recommended method for running the Nginx Proxy Manager. To begin, install Docker and the Docker Compose plugin on your system.

This tutorial covers the steps required for Debian and Ubuntu as well as AlmaLinux, CentOS Stream, Fedora, and Rocky Linux systems. For other operating systems and distributions, refer to the official instructions for installing Docker Engine.

Debian and Ubuntu

Remove any existing Docker installations:

sudo apt remove docker docker-engine docker.io containerd runc

Install the prerequisite packages for adding the Docker repository to the APT package manager:

sudo apt install ca-certificates curl gnupg lsb-release

Add the GPG key for the Docker repository for your distribution to the APT package manager:

Debian

sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Ubuntu

sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Add the Docker repository for your distribution to the APT package manager:

Debian

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Ubuntu

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Update the APT indices, then install the Docker Engine along with the Docker Compose plugin:

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

AlmaLinux, CentOS Stream, Fedora, and Rocky Linux

Remove any existing Docker installations:

sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine

Install the core plugins for the DNF package manager. These provide access to tools for managing DNF repositories.

sudo dnf -y install dnf-plugins-core

Add the Docker repository for your distribution to the DNF package manager:

AlmaLinux, CentOS Stream, and Rocky Linux

sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Fedora

sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo

Install the Docker Engine along with the Docker Compose plugin:

sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

If prompted to verify the GPG key, you should see the following key listed:

060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35

Once installed, ensure that the Docker daemon is running:

sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2023-02-16 20:38:07 UTC; 1s ago
     Docs: https://docs.docker.com

If it is not running (active), enable and start the Docker daemon with the following commands:

sudo systemctl enable docker
sudo systemctl start docker

Running the Nginx Proxy Manager

With the prerequisites in place, start up the Nginx Proxy Manager. This calls for deploying a Docker Compose configuration, which is provided in the steps below.

First, create a directory for the Nginx Proxy Manager’s Docker Compose files, and change into that directory. This tutorial uses the directory ~/nginx-proxy-manager/, and the remaining steps assume you are working out of this directory.

mkdir ~/nginx-proxy-manager/
cd ~/nginx-proxy-manager/

Create a docker-compose.yml file within the directory:

nano docker-compose.yml

Give the file the following contents:

version: "3"

networks:
  proxiable:
    name: proxiable

services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    container_name: nginxproxymanager
    restart: unless-stopped
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    ports:
      - '80:80'
      - '443:443'
      - '81:81'
    networks:
      - proxiable

  1. NoteThe Nginx Proxy Manager additionally supports configurations for working with MySQL/MariaDB. This tutorial does not employ these, but you can see the setup in the official instructions.When done, press CTRL+X, followed by Y then Enter to save the file and exit nano.
  2. Start up the Nginx Proxy Manager via Docker Compose:
sudo docker compose up -d

The Docker Compose configuration above contains an optional feature. The proxiable network allows you to run the Nginx Proxy Manager within the same Docker network as other services. This gives you the option of easy and secure communications between the proxy manager and your Docker services.

The example Grafana setup in the How to Expose a Service through the Nginx Proxy Manager section later in this guide leverages this feature. See the included Docker Compose configuration for how the network is included in the service.

Accessing the Nginx Proxy Manager Interface

The Nginx Proxy Manager can now accessible. Open a web browser and navigate to port 81 on the public IP address of the system that the proxy manager is running on.

For example, if you are running the Nginx Proxy Manager on a machine with a public IP address of 192.0.2.0, you would navigate to 192.0.2.0:81.

The Nginx Proxy Manager login screen should appear:

The setup creates a default administrator user with the following initial credentials, which the system prompts you to change after logging in:

  • Username: admin@example.com
  • Password: changeme

After logging in and updating the credentials for the administrator user, you are directed to the Nginx Proxy Manager dashboard. You can utilize the proxy manager’s features from this interface. The next section of the tutorial shows how to get started.

Related posts

How to Create Remote Desktop Gateway via Apache Guacamole on AlmaLinux 9

How to install ONLYOFFICE Workspace on Ubuntu

How to Install GLPI [IT Asset Management] Tool on RHEL Systems