Are you looking for a convenient tool to manage your proxy hosting? Look no further than the Nginx Proxy Manager. This powerful tool makes it incredibly easy to forward traffic to your services, whether they’re running on the cloud or your home network. In this article, we’ll introduce you to the Nginx Proxy Manager and show you how to get started with it.
What is the Nginx Proxy Manager?
The Nginx Proxy Manager is a user-friendly solution that allows you to create and manage proxy hosts. Traditionally, setting up and maintaining proxies can be a time-consuming and complex task. However, the Nginx Proxy Manager simplifies the process by packaging all the necessary steps into a convenient web interface. Once your services are up and running, you can easily create a proxy host within the Nginx Proxy Manager to forward traffic according to your specific requirements.
While the Nginx Proxy Manager may not offer some advanced features found in standard Nginx setups, such as load balancing, it is still an incredibly useful tool for many web service setups. It is particularly beneficial for deploying proxies for services running on-premise. Additionally, the Nginx Proxy Manager can be a valuable resource for administrators, offering server-monitoring tools and website administration interfaces.
In most cases, the convenience and ease of use provided by the Nginx Proxy Manager make it a compelling solution for managing your proxy hosting needs.
Running the Nginx Proxy Manager
Now that you understand the benefits of using the Nginx Proxy Manager, let’s dive into how you can install and run it on your system. We’ll walk you through the steps to get your Nginx Proxy Manager instance up and running.
Prerequisites: Installing Docker and Docker Compose
Before we can start with the installation of the Nginx Proxy Manager, we need to ensure that Docker and Docker Compose are installed on your system. Docker Compose is the recommended method for running the Nginx Proxy Manager. The following steps outline the installation process for different operating systems.
Debian and Ubuntu
If you’re using a Debian or Ubuntu system, follow these steps to install Docker and Docker Compose:
- 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 to the APT package manager:
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
- Add the Docker repository for your distribution to the APT package manager:
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
- 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
For AlmaLinux, CentOS Stream, Fedora, and Rocky Linux systems, follow these steps to install Docker and Docker Compose:
- 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:
sudo dnf -y install dnf-plugins-core
- Add the Docker repository for your distribution to the DNF package manager:
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/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
- Ensure that the Docker daemon is running:
sudo systemctl status docker
If the Docker daemon is not running, enable and start it with the following commands:
sudo systemctl enable docker sudo systemctl start docker
Starting the Nginx Proxy Manager
With Docker and Docker Compose installed, we can now start up the Nginx Proxy Manager. The following steps will guide you through the process.
- Create a directory for the Nginx Proxy Manager’s Docker Compose files and navigate to that directory. In this tutorial, we’ll use the directory
~/nginx-proxy-manager/
.
mkdir ~/nginx-proxy-manager/ cd ~/nginx-proxy-manager/
- Create a
docker-compose.yml
file within the directory using your preferred text editor. This file will contain the configuration for running the Nginx Proxy Manager.
nano docker-compose.yml
- Copy and paste the following contents into the
docker-compose.yml
file:
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
- Save the file and exit the text editor.
- Start up the Nginx Proxy Manager via Docker Compose:
sudo docker compose up -d
The Docker Compose configuration provided above includes an optional feature – the proxiable
network. This allows you to run the Nginx Proxy Manager within the same Docker network as other services, enabling easy and secure communication between the proxy manager and your Docker services. We’ll explore this feature in more detail later in this article.
Accessing the Nginx Proxy Manager Interface
With the Nginx Proxy Manager up and running, you can now access its user interface and start managing your proxy services. Follow the steps below to access the interface:
- Open a web browser and navigate to port 81 on the public IP address of the system where the Nginx Proxy Manager is running. For example, if the public IP address is 192.0.2.0, you would navigate to
http://192.0.2.0:81
. - The Nginx Proxy Manager login screen should appear. By default, a default administrator user is created with the following initial credentials:
- Username: admin@example.com
- Password: changeme
- After logging in with the initial credentials, you’ll be prompted to change your password. Follow the prompts to update the administrator user’s credentials.
- Once you’ve updated the credentials, you’ll be directed to the Nginx Proxy Manager dashboard. From here, you can utilize the features of the proxy manager to manage your proxy hosts and forward traffic to your services.
Let’s continue by exploring how to expose a service through the Nginx Proxy Manager.
Exposing a Service with the Nginx Proxy Manager
Now that you have the Nginx Proxy Manager set up, let’s see how you can use it to expose a service. In this example, we’ll demonstrate how to set up a reverse proxy for a Grafana monitoring service deployed with Docker Compose. However, you can easily adapt these steps to work with your own service.
Creating DNS Records
Before we can expose our service, we need to create DNS records to map our domain name to the proxy. Let’s walk through the process:
- Register a domain name if you haven’t already done so. You can use any domain name registrar service of your choice.
- If you’re using the Linode DNS Manager, insert the Linode name servers in your registrar’s interface.
- Create an A/AAAA DNS record that points your domain to the public IP address of the instance running your service.
- Optional: If you want to set up a reverse proxy for the Nginx Proxy Manager interface itself, create a separate A/AAAA record pointing to the same IP address. As an example, let’s use the subdomain
proxy-manager
for this record.
Setting Up the Service
To demonstrate the capabilities of the Nginx Proxy Manager, we’ll set up a Grafana monitoring service using Docker Compose. Follow the steps below to get started:
- Download the archive containing the necessary configuration files for Grafana and Prometheus: prometheus-grafana-compose.zip.
- Unzip the archive and navigate to the resulting directory. If needed, you can install the
unzip
package to complete this step. - Open the
docker-compose.yml
file in a text editor. This file contains the configuration for deploying the Grafana service. - Adjust the variables for administrator credentials (
GF_SECURITY_ADMIN_USER
andGF_SECURITY_ADMIN_PASSWORD
) to fit your needs. For enhanced security, consider using environment variables to store the actual credentials. - Optional: If you have custom Grafana dashboards in JSON format, you can add them to the
grafana/provisioning/dashboards/
directory. - Run the Docker Compose setup to start the Grafana service and its accompanying services:
sudo docker compose up -d
Configuring the Nginx Proxy Manager
With our service up and running, it’s time to configure the Nginx Proxy Manager to proxy requests to the Grafana service. Follow these steps:
- Access the Nginx Proxy Manager interface as described in the previous section.
- Navigate to the Proxy Hosts page either by clicking the “Proxy Hosts” button on the Dashboard or selecting “Hosts > Proxy Hosts” from the top menu bar.
- Click the “Add Proxy Host” button to create a new proxy host.
- In the form that appears, enter the domain name you want to use for your service in the “Domain Names” field.
- Leave the “Scheme” as “http” since it refers to the scheme used by Nginx to access the service, not the scheme used for the proxy itself.
- Enter the service address in the “Forward Hostname/IP” field. In our case, since the Grafana service runs in the same Docker network as the Nginx Proxy Service, we can simply enter the Docker container name
grafana
as the hostname. If your configuration is different, enter the appropriate local or public IP address. - Enter the service port in the “Forward Port” field. For our Grafana setup, the port is 3000.
- Toggle on the “Block Common Exploits” option for added security.
- Leave the remaining fields at their default values.
- Before saving the configuration, navigate to the “SSL” tab and complete the form as follows:
- Select “Request a new SSL Certificate” from the “SSL Certificate” drop-down.
- Toggle on the “Force SSL” option to ensure HTTPS is used for encrypting traffic.
- Enter an email address for the Let’s Encrypt certificate process.
- Read and agree to the terms of service for Let’s Encrypt.
- Save the configuration to complete the setup of the proxy host.
Congratulations! You’ve successfully set up a reverse proxy for your Grafana service using the Nginx Proxy Manager. Now you can access your service through your domain name, leveraging SSL encryption.
To access your Grafana service, navigate to the HTTPS address of your domain. For example, if your domain name is example.com
, you would navigate to https://example.com/
. You’ll be greeted with the Grafana login screen, where you can log in using the credentials you configured earlier.
Additionally, if you set up a reverse proxy for the Nginx Proxy Manager interface itself, you can access it using the subdomain or domain you configured. For example, if you used the subdomain proxy-manager
and your Grafana domain was example.com
, you would access the Nginx Proxy Manager interface at https://proxy-manager.example.com
.
Conclusion
In this article, we introduced you to the Nginx Proxy Manager and showed you how to install, configure, and use it to simplify and secure your proxy hosting. The Nginx Proxy Manager allows you to easily create and manage proxy hosts, making it a valuable tool for deploying proxies for services running on-premise or managing website administration interfaces.
By following the steps outlined in this article, you can set up a reverse proxy for your services, such as the Grafana monitoring service. With the Nginx Proxy Manager, you can leverage its convenience and ease of use to forward traffic according to your specific requirements.
Shape.host provides reliable and scalable Linux SSD VPS hosting services. With Shape.host, you can take advantage of their efficient cloud infrastructure to ensure the performance and security of your applications. Visit Shape.host today to explore their hosting solutions and experience the benefits of their reliable cloud hosting platform.
Now that you have the knowledge and tools to simplify and secure your proxy hosting, you can confidently manage your services with the Nginx Proxy Manager. Enjoy the convenience and efficiency it provides as you deploy and manage your proxies.