Install Nginx Proxy Manager on Ubuntu 24.04

By Anurag Singh

Updated on Oct 01, 2024

Install Nginx Proxy Manager on Ubuntu 24.04

In this tutorial, we'll learn how to install Nginx Proxy Manager on Ubuntu 24.04 server.

Nginx Proxy Manager is a user-friendly, web-based interface designed to simplify the management of Nginx as a reverse proxy. It allows users to manage proxy hosts, SSL certificates, and forwarding rules without the need to manually configure Nginx. The tool is particularly useful for handling web traffic to multiple applications running on a single server by routing requests to the appropriate service.

Key features of Nginx Proxy Manager include:

  • Reverse Proxy Management: It enables you to easily set up reverse proxies for web applications, allowing you to forward domain traffic to different services.
  • SSL Support: Integrated with Let's Encrypt, it provides automated SSL certificate generation and renewal, ensuring secure traffic.
  • Web-Based GUI: Instead of managing configurations through the command line, the platform offers a graphical interface to add, edit, and manage proxy hosts and settings.
  • User Management: It supports multi-user setups, allowing you to create and manage different user accounts with specific access rights.
  • Streamlined Domain and Certificate Handling: You can manage multiple domains and their certificates effortlessly, reducing manual setup complexity.

This guide will show you how to install Nginx Proxy Manager on Ubuntu 24.04 step-by-step.

Prerequisites

Before we begin, ensure you have the following:

Install Nginx Proxy Manager on Ubuntu

Step 1: Update Your Server

Start by updating your server’s package list to ensure that all software is up-to-date.

sudo apt update && sudo apt upgrade -y

Step 2: Install Docker

Nginx Proxy Manager uses Docker, so the first step is to install Docker and Docker Compose.

Install Docker:

Run the following commands to install Docker:

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

To install the latest version, run:

sudo apt-get install docker-ce

Verify the installation:

docker --version

You should see the Docker version output.

Next, install Docker Compose:

Download Docker Compose binary:

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

Set executable permissions:

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

Verify installation:

docker-compose --version

Step 3: Create a Directory for Nginx Proxy Manager

Now that Docker is installed, let’s set up Nginx Proxy Manager.

Create a directory:

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

Step 4: Create Docker Compose File

We will use Docker Compose to manage Nginx Proxy Manager containers. Inside the nginx-proxy-manager directory, create a docker-compose.yml file.

Create the docker-compose.yml file:

nano docker-compose.yml

Add the following configuration:

services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: always
    ports:
      - '80:80'   # HTTP
      - '81:81'   # Admin GUI
      - '443:443' # HTTPS
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm_password"
      DB_MYSQL_NAME: "npm"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
  db:
    image: 'mariadb:latest'
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 'root_password'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm_password'
    volumes:
      - ./db:/var/lib/mysql
  • ports: Expose ports for HTTP (80), Admin GUI (81), and HTTPS (443).
  • Replace root_password and npm_password with your secure passwords.
  • volumes: These define where data and certificates will be stored on the host system.

Step 5: Start Nginx Proxy Manager with Docker Compose

Once the docker-compose.yml file is configured, you can start the Nginx Proxy Manager using Docker Compose.

Run Docker Compose:

docker-compose up -d

The -d flag runs the containers in detached mode, allowing you to continue using the terminal.

Verify if the containers are running:

docker-compose ps

You should see both the Nginx Proxy Manager and the MariaDB container running.

Step 6: Access Nginx Proxy Manager

Now that the Nginx Proxy Manager is running, you can access the web-based interface.

Open your browser and navigate to http://<your-server-ip>:81.

Nginx proxy manager login HostMyCode

Login with the default credentials:

Email: admin@example.com
Password: changeme

Change the default credentials: After logging in, you will be prompted to change the email and password. Set a strong password to secure your system.

Step 7: Secure Nginx Proxy Manager

To secure access to the Nginx Proxy Manager (NPM) panel via HTTPS using a hostname (e.g., https://hostname instead of http://serverip:81), you need to follow these steps. This includes setting up a domain name for the panel, configuring DNS records, and obtaining an SSL certificate with Let's Encrypt.

Access Nginx Proxy Manager's Web UI

Login to the NPM Panel by accessing http://serverip:81.
Enter your login credentials.

Add a New Proxy Host for the NPM Panel

To make the Nginx Proxy Manager itself accessible via HTTPS on a domain name, you need to create a reverse proxy rule for its own interface.

  • Go to the "Hosts" tab in Nginx Proxy Manager and select "Proxy Hosts".
  • Click "Add Proxy Host" to create a new proxy host.

Configure Proxy Host

In the proxy host creation form:

  • Domain Names: Enter your domain name or subdomain (e.g., npm.yourdomain.com).
  • Scheme: Select "http" (since you're forwarding the admin interface, which is accessible via HTTP on port 81).
  • Forward Hostname/IP: Enter the hostname of your server (e.g., localhost).
  • Forward Port: Enter the port 81 (because the Nginx Proxy Manager admin panel runs on this port by default).
  • Enable Websockets Support: Enable this option to allow WebSocket connections, which might be required by some services.
  • SSL Tab:
  • Select "Request a new SSL Certificate" to automatically issue an SSL certificate via Let's Encrypt.
  • Check "Force SSL": This option ensures that all traffic is redirected to HTTPS.
  • Agree to the Let’s Encrypt terms of service by checking the box.

Save the configuration.

Test the HTTPS Access

Once the proxy host is created, wait for Nginx Proxy Manager to automatically issue the SSL certificate for your domain/subdomain via Let's Encrypt.

Open your browser and navigate to https://npm.yourdomain.com.

You should now be able to access the Nginx Proxy Manager panel securely via HTTPS.

Step 8: Set Up Reverse Proxy Hosts

Once logged in, you can start creating reverse proxy hosts for your applications.

  • Go to Hosts > Proxy Hosts in the dashboard.
  • Click "Add Proxy Host" to add a new host.

Fill in the details:

  • Domain Names: Enter the domain name you want to forward.
  • Scheme: Choose HTTP or HTTPS based on the backend service.
  • Forward Hostname / IP: Enter the IP address or hostname of the service you’re proxying.
  • Forward Port: The port of the backend service.

SSL Configuration: You can use Let's Encrypt to enable SSL for your domain directly from the Nginx Proxy Manager interface.

Save your settings.

Nginx Proxy Manager will now handle reverse proxying for your applications.

Step 8: Enable SSL with Let’s Encrypt

To secure your reverse proxy with SSL, you can easily enable Let’s Encrypt certificates.

  • Go to the SSL tab while setting up the proxy host.
  • Select "Request a new SSL Certificate."
  • Check "Force SSL" to redirect all HTTP traffic to HTTPS.
  • Click "Save."

Nginx Proxy Manager will automatically request and install the SSL certificate from Let's Encrypt.

Step 9: Managing Proxy Hosts and Certificates

From the Nginx Proxy Manager dashboard, you can manage multiple reverse proxy hosts and certificates. You can also monitor the status of certificates and renew them automatically.

Step 10: Managing Docker Containers (Optional)

If you need to stop or restart the Nginx Proxy Manager containers, you can do so using Docker commands:

Stop containers:

docker-compose down

Restart containers:

docker-compose up -d

Conclusion

We have seen how to install Nginx Proxy Manager on Ubuntu 24.04 server. With its user-friendly GUI, you can now manage reverse proxies, SSL certificates, and much more with ease. This setup provides a streamlined way to handle multiple web services under a single interface while securing them with Let’s Encrypt.

Feel free to explore additional features like access lists, redirection hosts, and more!