How to Self-Host Nginx Proxy Manager on a VPS (Complete Guide)
Nginx Proxy Manager is a powerful tool for managing Nginx reverse proxies through a web interface. Whether youโre running personal projects or managing traffic for multiple applications, Nginx Proxy Manager can simplify your workflow. In this guide, we will walk through the steps to install and configure Nginx Proxy Manager on a VPS.
Why Use Nginx Proxy Manager?
Nginx Proxy Manager provides several features that make it ideal for self-hosting environments:
- Web Interface: A convenient GUI for managing proxies, hosts, and SSL certificates.
- SSL Management: Easy SSL certificate management through Letโs Encrypt.
- Access Control: Role-based access to secure your applications.
Recommended VPS Providers
Choosing the right VPS provider is essential for your self-hosting setup. Hereโs a comparison of some of the top options:
| Provider | Price (per month) | Memory | Storage |
|---|---|---|---|
| Contabo VPS | 5.99 EUR | 8 GB | 200 GB SSD |
| Hetzner Cloud | 4.15 EUR | 8 GB | 240 GB NVMe |
| DigitalOcean | 6 USD | 8 GB | 160 GB SSD |
| Vultr | 6 USD | 8 GB | 160 GB SSD |
| Linode (Akamai) | 5 USD | 8 GB | 160 GB SSD |
For a full VPS comparison, check out our guide here.
Prerequisites
Before we begin, ensure you have the following:
- A VPS instance running Ubuntu 20.04 or a compatible Linux distribution.
- A domain name pointing to your VPS (for example,
example.com). - Basic knowledge of Linux command line and Docker.
Step-by-Step Installation Guide
Step 1: Access Your VPS
First, connect to your VPS via SSH. Replace your_user and your_ip with your credentials:
ssh your_user@your_ip
Step 2: Install Docker and Docker Compose
Nginx Proxy Manager uses Docker for deployment. Ensure you have Docker and Docker Compose installed on your VPS. Run the following commands:
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
sudo systemctl start docker
sudo systemctl enable docker
Now install Docker Compose:
sudo apt install -y docker-compose
Step 3: Create a Docker Compose File
Create a directory for Nginx Proxy Manager 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
container_name: nginx-proxy-manager
restart: always
ports:
- "80:80"
- "443:443"
- "81:81"
environment:
DB_SQLITE_FILE: "/data/database.sqlite"
volumes:
- ./data:/data
Step 4: Launch Nginx Proxy Manager
Run the following command to start the Docker container:
sudo docker-compose up -d
This command will download the image and start Nginx Proxy Manager in detached mode.
Step 5: Access the Web Interface
Once the container is running, you can access the Nginx Proxy Manager web interface through your browser at http://your_ip:81.
Log in with the default credentials:
- Email:
[email protected] - Password:
changeme
Be sure to change the default password immediately after logging in.
Step 6: Set Up Your Proxy Hosts
In the web interface, navigate to the โProxy Hostsโ tab to create new hosts that forward traffic to your self-hosted applications. Here are the basic steps:
- Click on โAdd Proxy Hostโ.
- Enter your domain (e.g.,
app.example.com). - Input the forward hostname/IP and port of your application.
- Configure SSL settings as required and click โSaveโ.
Frequently Asked Questions
How do I install Nginx Proxy Manager on DigitalOcean specifically?
To install Nginx Proxy Manager on DigitalOcean, you should follow the same steps outlined in this guide. The installation is environment-agnostic, meaning that as long as you use an Ubuntu 20.04 VPS, the commands will be the same. Access your VPS via SSH, ensure Docker and Docker Compose are installed, and follow the Docker Compose instructions. The process is straightforward and allows you to manage traffic easily.
Can I use Nginx Proxy Manager for multiple domains?
Yes, Nginx Proxy Manager supports managing multiple domains and subdomains seamlessly. You can create multiple proxy hosts within the web interface, allowing you to forward requests from different domains to their respective applications hosted on your VPS. This feature is particularly useful for developers managing several projects or services from a single VPS instance. Just remember to set up the DNS records for your domains to point to your VPS.
What should I do if Nginx Proxy Manager is not accessible?
If you cannot access Nginx Proxy Manager after installation, check the following:
- Ensure the Docker container is running by executing
sudo docker psto see active containers. - Verify that the firewall settings on your VPS permit inbound traffic on ports 80, 443, and 81.
- Double-check your domain DNS settings to make sure they correctly resolve to your VPS IP address. If necessary, restart the Docker container with
sudo docker-compose restart.
By following the steps in this guide, you can effectively install and configure Nginx Proxy Manager on your VPS, enabling you to self-host with ease. For additional community support and projects, refer to r/selfhosted or browse the awesome-selfhosted list for more tools and applications.