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:

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:

  1. Open your AdGuard Home web interface.

  2. From the menu bar, select Filters > DNS rewrites.

  3. Click Add DNS rewrite.

  4. 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

  5. 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.

  1. Open PowerShell.

  2. Create a new folder called nginx-proxy-manager and navigate to it using this command:

    mkdir nginx-proxy-manager && cd nginx-proxy-manager

  3. Create a docker-compose.yml file and open it using Notepad with the following command:

    notepad docker-compose.yml

  4. 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.

    version: '3.8'
    services:
      app:
        container_name: nginx-proxy-manager
        image: 'jc21/nginx-proxy-manager:latest'
        restart: unless-stopped
        ports:
          - '80:80'
          - '443:443'
          - '81:81'
        volumes:
          - ./data:/data
          - ./letsencrypt:/etc/letsencrypt

  5. Press Ctrl + S to save changes.

  6. 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-compose up -d

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.

  1. Open your internet browser.

  2. In the URL bar, enter localhost:81/ and press Enter.

  3. 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.

  1. From the NPM dashboard, select Proxy hosts.

  2. Click Add proxy host.

  3. 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

  4. 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

© 2024 Nord Security. All Rights Reserved.