How to assign custom host names to Meshnet services using Nginx proxy manager
Learn how to use the Nginx proxy manager to create custom host names for Meshnet services.
Introduction
As the popularity of self-hosted services continues to grow, so does the challenge of managing multiple IP addresses, host names, and port numbers. It can quickly become overwhelming to keep track of which port number to enter for services like Home Assistant, Jellyfin, or LibrePhotos.
While a custom DNS server can help overcome the problem of remembering the IP addresses or host names of your peer devices, it's not enough to handle requests that need to be forwarded to a specific port number. This is where a reverse proxy, such as the Nginx proxy manager (NPM), can come in handy. With NPM, you can easily create reverse proxies without needing prior networking knowledge. By combining a custom DNS server with NPM, you can eliminate the need to remember and enter port numbers altogether.
This article showcases the process of setting up the Nginx proxy manager alongside a DNS server to create custom host names for your Meshnet services, simplifying their management.
Prerequisites
Before you begin the setup process, make sure that:
You have a custom DNS server set up on your network. For example, AdGuard Home.
You have changed the DNS addresses of your devices to your custom DNS server.
Port 80 is not in use by any service on your system.
Creating DNS rewrites
Note
For this configuration, a standard AdGuard Home installation is used as an example DNS server. If you are running your DNS server using Docker, the steps may differ.
To start, you need a way to create DNS rewrites from a custom host name to a specific IP or host name. While this can be achieved by editing your operating system’s hosts
file, a much more convenient and easily manageable alternative is a custom DNS server.
To create a DNS rewrite using AdGuard Home:
Open your AdGuard Home web interface.
From the menu bar, select Filters > DNS rewrites.
Click Add DNS rewrite.
In the pop-up window, fill in the following information:
In the upper field, enter a custom host name that you want to use to access a specific service.
In the lower field, enter
localhost
.Example
Click Save.
You should now see a new entry in the DNS rewrites table. Repeat this procedure for any other host names you want to create.
Tip
AdGuard Home supports wildcard domain names. You can use the format *.example.com
to redirect all subdomains of example.com
. This way, you don’t have to add new DNS entries for each service.
Setting up the Nginx proxy manager
With the DNS rewrites created, you can deploy your Nginx proxy manager instance. To set up NPM, you need to use Docker Compose.
Create a Docker Compose file
First, you need to create a Docker Compose file containing instructions for NPM.
Open PowerShell.
Create a new folder called
nginx-proxy-manager
and navigate to it using this command:Create a
docker-compose.yml
file and open it using Notepad with the following command:In the Notepad window, paste the following information that specifies the NPM docker image, publishes the required ports, and creates two new folders in your working directory.
Press Ctrl + S to save changes.
Exit Notepad.
Deploy NPM
With the Compose file created, while in the nginx-proxy-manager
directory, execute the following command in the command line to create your NPM instance:
Docker will pull the NPM image from Docker Hub and create the container.
Log in to your NPM web interface
Once the container is active, you can visit the NPM web interface.
Open your internet browser.
In the URL bar, enter
localhost:81/
and press Enter.Log in using the default email (
admin@example.com
) and password (changeme
).
After logging in, you will be asked to change the details of your account. Follow the on-screen instructions to update your credentials.
Create proxy redirects
Finally, you can create a proxy redirect for your created host name to reach a specific service.
From the NPM dashboard, select Proxy hosts.
Click Add proxy host.
In the new window, specify the following information:
In the Domain names field, enter the custom host name you created in the Creating DNS rewrites section.
In the Forward hostname / IP field, type in the Nord name or the Meshnet IP address of your Meshnet peer device.
In the Forward port field, enter a port number that the peer device’s service is using. Example
Click Save.
You should see a new entry for your proxy appear in the Proxy hosts table.
Accessing Meshnet services using the reverse proxy
Now you can access your Meshnet services without needing to specify the Nord name or the port that you want to reach. Simply enter the custom host name into the search field of your internet browser and your specified service will open.
Last updated