How To Configure Nginx as Reverse Proxy for Listmonk

This article gives a walkthrough of how to configure Nginx as a Reverse Proxy for use with Listmonk. This is the second article in the series on how to install and configure listmonk, the first can be found here. [link]

NOTE: This process has been used by many others but I have personally tested this on Ubuntu and Ubuntu server and have had success, this process will be modified if you are using a non-debian based linux distribution or are using Windows and/or MacOS.

NOTE: This article is heavily based off of an article written by Ramces Red on Make Tech Easier. This version had been adapted from his with updated/corrected code and language improvements. Link to the origional article at the time of posting [MakeTechEasier]


Nginx Installation

For the sake of this article I will not go over the process of installing Nginx, the explanations and guides on that process have been done far better by far more individuals and it does not merit rehashing. Erin Glass from Digital Ocean did a spectacular job of guiding you through the installation configuration, and even firewall configuration process for Nginx, his article is linked here. [Erin Glass's Article]

Ensure you have Nginx installed and configured prior to continuing down this article.



Configuring Nginx


Create Nginx Reverse Proxy

Even though Listmonk has started running on a Docker instance, it is not publicly accessible until you have configured a reverse proxy to link to it. Follow the instructions below to configure an Nginx reverse proxy.

Create a new site configuration file for your Listmonk instance


sudo nano /etc/nginx/sites-available/listmonk
        

Paste the following code into the site configuration file


server {

    server_name [INSERT_TOP/SUBDOMAIN_NAME_HERE];

    location / {
            proxy_pass http://127.0.0.1:9000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
    }
}
        

Link your new configuration file from /etc/nginx/sites-available to /etc/nginx/sites-enabled


sudo ln -s /etc/nginx/sites-available/listmonk /etc/nginx/sites-enabled/
        

Restart the Nginx server daemon using the following command


sudo systemctl reload nginx
        


Installing & Provisioning SSL Certificate

Once you have configured the reverse proxy, your site will be accesible to the outside world. It will not be secure through any data transmitted to it will not be encrypted. Installing an SSL certificate will secure the site and enable HTTPS.

Ensure the core snap daemon is running on your system


sudo snap install core
        

Install the certbot snap package from the Electronic Frontier Foundation. This will allow a SSL certificate to be requested and communications encrypted.


sudo snap install certbot --classic
        

Test the certbot package is properly running by regitering it to the EFF


sudo certbot register --agree-tos -m [your@email.address]
        

Obtain a new SSL certificate for your Listmonk installation by running the following command


sudo certbot --nginx -d [YOUR_DOMAIN_HERE]
        


---

En Voilà! Listmonk is installed and accessible to the outside world! If you stumbled upon this article but cannot find the first one, the installation process for Listmonk is linked below.

LAST ARTICLE: [How To Install Listmonk]

---

Back To Article Page
Back To Home Page