Nginx Reverse Proxy on Ubuntu 26.04 LTS

Web Servers

By Jennifer Webb

Updated on Aug 16, 2026

Nginx Reverse Proxy on Ubuntu 26.04 LTS

Learn how to configure an Nginx reverse proxy on Ubuntu 26.04 LTS with a working server block, tests, and rollback steps.

Introduction

This tutorial configures Nginx as a reverse proxy on Ubuntu 26.04 LTS for a dedicated server, using a server block that forwards requests to an upstream application. It is aimed at practitioners who need a clean, verifiable proxy layer in front of a backend service.

You will install Nginx, create a dedicated reverse proxy server block, test the configuration, verify request forwarding with curl, and roll the change back if needed.

Prerequisites

  • A dedicated server running Ubuntu 26.04 LTS
  • Root access or a normal administrative user with sudo privileges
  • Network access for package installation
  • An upstream application listening on the local system or a reachable backend endpoint
  • Basic familiarity with editing Nginx configuration files

Tutorial steps

First, update package metadata and install Nginx, then start and enable the service so the proxy is available after reboot.

sudo apt update
sudo apt install nginx
sudo systemctl enable --now nginx

If you need a refresher on installation details, see Install Nginx on Ubuntu 26.04 LTS.

Create a new server block for the reverse proxy.

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

Add a complete server block that forwards traffic to your upstream application. Replace the upstream address and port with the backend you intend to proxy.

server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Enable the site by linking it into sites-enabled.

sudo ln -s /etc/nginx/sites-available/reverse-proxy /etc/nginx/sites-enabled/

Before reloading Nginx, validate the configuration syntax.

sudo nginx -t

If the test succeeds, reload Nginx to apply the new reverse proxy server block.

sudo systemctl reload nginx

Verification

Confirm that Nginx is active on the dedicated server.

systemctl status nginx

Use curl to confirm that Nginx responds locally on port 80.

curl -I http://127.0.0.1

Then send a request with a host header that matches the configured server name to confirm the reverse proxy path is selected.

curl -H 'Host: example.com' http://127.0.0.1

For a healthy proxy path, you should receive the expected HTTP response from the upstream application, such as a successful status code or the backend's normal response headers.

Troubleshooting

If the proxy returns 502 Bad Gateway or the upstream does not respond, inspect the Nginx error log for the backend failure details.

sudo tail -n 50 /var/log/nginx/error.log

Common causes include the upstream process not listening on the configured address or port, the proxy target being unreachable, or a mismatch between the server name and the host header used in testing.

Re-run sudo nginx -t after any configuration edit so you can catch syntax issues before reloading Nginx again.

Rollback

To remove the reverse proxy site, delete the enabled symlink and reload Nginx.

sudo rm /etc/nginx/sites-enabled/reverse-proxy
sudo systemctl reload nginx

If you no longer need the configuration file, remove the matching file from sites-available as well after confirming the rollback is complete.

Conclusion

You have configured an Nginx reverse proxy on Ubuntu 26.04 LTS for a dedicated server, validated the server block, and confirmed that requests can be forwarded to an upstream application. You can now verify Nginx status, test the proxy with curl, and roll back the site cleanly if needed.