Nginx Proxy Manager
Update and Upgrade Your Ubuntu System
Before installing any new software, it’s essential to ensure your Ubuntu system is up-to-date. This step helps prevent potential conflicts and ensures you have the latest security patches. Open a terminal and run these commands:
sudo apt update
sudo apt upgrade -y
Install Docker
-
Install required packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
-
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
-
Add the Docker repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"| sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
-
Update the package database:
sudo apt update
-
Install Docker:
sudo apt install docker-ce docker-ce-cli containerd.io -y
After installation, verify that Docker is running correctly by executing:
sudo systemctl status docker
You should see output indicating that the Docker service is active and running.
Install Docker Compose
Docker Compose is a tool for defining and running multi-container Docker applications. We’ll use it to manage the Nginx Proxy Manager container. Install Docker Compose with these commands:
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)"-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Verify the installation by checking the Docker Compose version:
docker-compose --version
You should see the version number of Docker Compose displayed in the terminal.
Create Docker Compose File for Nginx Proxy Manager
With Docker and Docker Compose installed, we’ll now create a Docker Compose file to define the Nginx Proxy Manager container and its configuration. This file will specify the image, port mappings, and volume mounts.
First, let’s create a new directory for Nginx Proxy Manager and navigate to it:
mkdir ~/nginx-proxy-manager
cd ~/nginx-proxy-manager
Create and edit the docker-compose.yml file using your preferred text editor. Here’s an example using nano:
nano docker-compose.yml
Copy and paste the following content into the file:
version:'3'
services:
app:
image:'jc21/nginx-proxy-manager:latest'
restart:unless-stopped
ports:-'80:80'-'81:81'-'443:443'
volumes:-./data:/data
-./letsencrypt:/etc/letsencrypt
environment:
DB_MYSQL_HOST:"db"
DB_MYSQL_PORT:3306
DB_MYSQL_USER:"npm"
DB_MYSQL_PASSWORD:"npm"
DB_MYSQL_NAME:"npm"
db:
image:'jc21/mariadb-aria:latest'
restart:unless-stopped
environment:
MYSQL_ROOT_PASSWORD:'npm'
MYSQL_DATABASE:'npm'
MYSQL_USER:'npm'
MYSQL_PASSWORD:'npm'
volumes:-./data/mysql:/var/lib/mysql
Save the file and exit the text editor. This configuration sets up two containers: one for Nginx Proxy Manager and another for its database (MariaDB).
Deploy Nginx Proxy Manager
With the Docker Compose file in place, we’re ready to deploy Nginx Proxy Manager. Run the following command in the directory containing the docker-compose.yml file:
sudo docker-compose up -d
The -d flag runs the containers in detached mode, allowing them to run in the background. Docker will pull the necessary images and start the containers.
To verify that the containers are running correctly, use:
sudo docker-compose ps
You should see two containers listed as “Up” in the status column.
Access Nginx Proxy Manager Web Interface
With the containers running, you can now access the Nginx Proxy Manager web interface. Open a web browser and navigate to:
http://your_server_ip:81
RReplace your_server_ip
with the actual IP address of your Ubuntu server. You’ll be greeted with the Nginx Proxy Manager login page.
For the initial login, use these default credentials:
- Email:
[email protected]
- Password: changeme
After logging in, you’ll be prompted to change the default email and password. Choose a strong, unique password to secure your Nginx Proxy Manager installation.
Congratulations! You’ve successfully installed Nginx Proxy Manager on Ubuntu 24.04 LTS.
Configure Nginx Proxy Manager
Now that you’ve logged into the Nginx Proxy Manager web interface, you can begin configuring your proxy hosts. Here’s a step-by-step guide to add a new proxy host:
- Click on “Proxy Hosts” in the sidebar menu.
- Click the “Add Proxy Host” button.
- Fill in the details:
- Domain Names: Enter the domain name(s) for your website.
- Scheme: Select HTTP or HTTPS for the backend server.
- Forward Hostname / IP: Input the IP address or hostname of your backend server.
- Forward Port: Specify the port your backend server is listening on (e.g., 80 for HTTP, 443 for HTTPS).
- Configure SSL settings if required.
- Set up additional options such as caching or WebSocket support.
- Click “Save” to create the proxy host.
Repeat this process for each website or application you wish to proxy through Nginx Proxy Manager.
Managing Proxy Hosts
Nginx Proxy Manager simplifies the management of your proxy hosts. Here are some common tasks:
- Edit an existing proxy host by clicking the edit icon next to its entry in the Proxy Hosts list.
- Delete a proxy host by clicking the delete icon and confirming the action.
- Enable or disable proxy hosts using the toggle switch in the “Enabled” column.
Always test your configuration after making changes to ensure everything works as expected.
SSL Certificate Management
Nginx Proxy Manager offers built-in SSL certificate management—a standout feature. To set up SSL for a proxy host:
- Navigate to the “SSL Certificates” section in the sidebar.
- Click “Add SSL Certificate”.
- Choose between “Let’s Encrypt” for free, auto-renewing certificates, or “Custom” to upload your own.
- For Let’s Encrypt:
- Enter the domain names you want to secure.
- Provide a valid email address for renewal notifications.
- Accept the Let’s Encrypt Terms of Service.
- Click “Save” to generate and install the certificate.
After creating the certificate, assign it to your proxy hosts by editing them and selecting the appropriate certificate in the SSL section.
Backup and Restore
Regular backups are crucial for any system. To backup Nginx Proxy Manager data:
-
Stop the Docker containers:
sudo docker-compose down
-
Create a backup of the data directory:
sudo tar -czvf npm_backup_$(date +%Y%m%d).tar.gz ~/nginx-proxy-manager
-
Restart the containers:
sudo docker-compose up -d
To restore from a backup, stop the containers, replace the data directory with the backed-up version, and restart the containers.
Updating Nginx Proxy Manager
To update Nginx Proxy Manager to the latest version:
- Navigate to the directory containing your docker-compose.yml file.
-
Pull the latest images:
sudo docker-compose pull
-
Update and restart the containers:
sudo docker-compose up -d
Always check the Nginx Proxy Manager GitHub repository for any specific update instructions or breaking changes before updating.
Reference
https://idroot.us/install-nginx-proxy-manager-ubuntu-24-04/