A reverse proxy sits in front of one or more backend application servers and forwards client requests to them. Nginx excels as a reverse proxy — it handles SSL termination, load balancing, caching, and rate limiting while passing traffic to Node.js, Python, Java, or other apps. This guide configures Nginx as a reverse proxy on Ubuntu 26.04 LTS.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS server with Nginx installed
- A backend application running on a local port (e.g., Node.js on port 3000)
- A domain name or public IP
Step 1 – Confirm Your Backend is Running
Example: a Node.js app on port 3000:
curl http://localhost:3000
Step 2 – Create an Nginx Server Block for the Proxy
sudo nano /etc/nginx/sites-available/myapp
Add the following configuration:
server {
listen 80;
server_name myapp.example.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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;
proxy_cache_bypass $http_upgrade;
}
}
Step 3 – Enable the Site
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
Step 4 – Test and Reload Nginx
sudo nginx -t
sudo systemctl reload nginx
Step 5 – Test the Proxy
curl http://myapp.example.com
Step 6 – Add SSL with Certbot
sudo certbot --nginx -d myapp.example.com
Step 7 – Tune Proxy Timeouts (optional)
For long-running requests, increase timeouts inside the location block:
proxy_connect_timeout 60s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
Conclusion
Nginx is now acting as a reverse proxy on Ubuntu 26.04 LTS, forwarding requests to your backend application. This setup lets you run multiple apps on different ports behind a single IP, all served over HTTPS.