Menu
User

DropVPS Team

Writer: John hens

how to install nginx reverse proxy on ubuntu 25.04

how to install nginx reverse proxy on ubuntu 25.04

Publication Date

10/11/2025

Category

Articles

Reading Time

3 Min

Table of Contents

Setting up Nginx as a reverse proxy on Ubuntu 25.04 is a simple yet powerful way to improve your website’s performance, security, and scalability. A reverse proxy acts as an intermediary between clients and your backend servers, efficiently managing requests, reducing server load, and enabling HTTPS easily.

Step 1: Update and Install Nginx

Before installing Nginx, it’s a good idea to update your Ubuntu system to make sure all existing packages are current. This helps prevent errors during installation and keeps your server secure and stable for running Nginx efficiently.

sudo apt update && sudo apt upgrade -y
sudo apt install nginx -y

Step 2: Enable and Check Nginx

After installing Nginx, you need to ensure that the service is running and will start automatically after a reboot. This step guarantees that your web server stays active without manual intervention.

sudo systemctl enable nginx
sudo systemctl start nginx

Step 3: Allow Web Traffic

To make your website accessible from the internet, you must open HTTP and HTTPS ports on the firewall. Allowing Nginx traffic ensures that visitors can connect securely to your server.

sudo ufw allow 'Nginx Full'
sudo ufw reload

Step 4: Configure Reverse Proxy

Now that Nginx is running, let’s configure it as a reverse proxy. This means Nginx will forward requests from users to your backend application, helping improve performance and security.

sudo nano /etc/nginx/sites-available/reverse-proxy.conf

Add this simple configuration inside the file:

server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Step 5: Enable Config and Restart

Once the configuration file is ready, activate it by linking it to the enabled sites directory. Then restart Nginx to apply all the new settings immediately.

sudo ln -s /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Step 6: Enable HTTPS

Adding an SSL certificate protects your website and builds user trust. Using Let’s Encrypt, you can enable HTTPS for free and also improve your site’s SEO ranking.

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d example.com

 

Linux VPS
U
Loading...

Related Posts