How to Configure a Reverse Proxy with Nginx

How to Configure a Reverse Proxy with Nginx

If you are still confused about how to configure a Reverse Proxy with Nginx, you can follow the tutorial on this page from installing Nginx to completion.

For your information, we previously discussed how to install Uptime Kuma, but with that installation, the uptime page needs to be accessed via an IP and Port that are hard to remember. To make access easier, we can use a Reverse Proxy, for example, so that Uptime Kuma can be accessed via kuma.wpgan.biz.id.

How to Configure a Reverse Proxy with Nginx

Because this tutorial continues from the previous how to install Uptime Kuma article, the server used is also the same, where we are using Ubuntu 25.04.

1. Ensure the Domain Points to the Server

Before starting with Nginx, ensure your domain or subdomain already points to the server. You can use online tools like DNS Checker to check whether your domain points to the server or not

2. Update and Upgrade Packages

Now you can access your server via SSH and ensure the packages on the server are updated to the latest version

sudo apt-get updatesudo apt-get upgrade -y

3. Install Nginx

If the update is finished, you can immediately install Nginx

sudo apt install nginx

If the installation is finished, you can check the Nginx status

sudo systemctl status nginx

4. Enable Nginx

If the Nginx status is not running, you can start it first

sudo systemctl start nginx

It is also recommended to enable Nginx so it can automatically run when the server reboots

sudo systemctl enable nginx

5. Verify Nginx Installation

For other verification, you can try accessing your server IP address or the subdomain you have pointed to the server. If Nginx is running normally, you will see the default Nginx page

If you get a connection refused error message, ensure you have allowed IP 80 and 443 in the firewall

ufw allow 80ufw allow 443

So that it does not display the default Nginx page when accessed, you can unlink the default configuration

sudo unlink /etc/nginx/sites-enabled/default

7. Create a New Configuration

Now you can create a new configuration inside the /etc/nginx/sites-availablefolder, for example with the name kuma-wpgan.conf

sudo nano /etc/nginx/sites-available/kuma-wpgan.conf

Inside the kuma-wpgan.conf file, fill it with the Reverse Proxy configuration

server  { listen 80;     server_name    kuma.wpgan.biz.id;     location / {         proxy_pass         http://localhost:3001;         proxy_http_version 1.1;             proxy_set_header   Upgrade $http_upgrade;         proxy_set_header   Connection "upgrade";         proxy_set_header   Host $host;     } }
  • server_name: the domain or subdomain name that will be used to access Uptime Kuma (or other applications)
  • proxy_pass: access to the application complete with the port, for Uptime Kuma, the default uses 3001

8. Enable Reverse Proxy

After the configuration is saved, you need to enable the Reverse Proxy you just created

sudo ln -s /etc/nginx/sites-available/kuma-wpgan.conf /etc/nginx/sites-enabled/kuma-wpgan.conf

Also ensure to restart Nginx after you enable the Reverse Proxy

service nginx restart

You can also check whether there are errors in the configuration or not with configtest

sudo service nginx configtest

9. Access the Website with a Domain

Because all processes are finished, now you can try accessing the website using the domain and if successful, you can access Uptime Kuma or other applications without having to write down the IP address and Port that are hard to remember

That is the easy way to configure a Reverse Proxy with Nginx that you can apply. However, this method still has not added SSL so the website cannot be accessed with https.

If you want to use SSL, you can follow this tutorial: How to Install SSL on an Nginx Server

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...