Nginx Reverse Proxy Setup | Ubuntu 22.04 & 24.04
Nginx Reverse Proxy Configuration Guide
The safest way to expose an application server (Node.js, Python, Go, etc.) to the internet is to place a reverse proxy in front of it.
This architecture; It provides security, SSL management and scalability advantages.
What Will You Learn in This Guide?
- Installing Nginx on Ubuntu
- Route traffic with
proxy_pass - Transferring client IP and protocol information to the backend
- Automatic SSL setup with Let's Encrypt
1. Installing Nginx Server
Nginx is included in Ubuntu's default repositories.
sudo apt update
sudo apt install nginx
- These commands install the Nginx web server on the system.
Allow HTTP traffic on the firewall:
sudo ufw allow 'Nginx HTTP'
2. Creating a Server Block (Virtual Host)
- Create a domain-specific file instead of changing the default configuration.
sudo nano /etc/nginx/sites-available/ornek.com
Example configuration:
server {
listen 80;
server_name ornek.com www.ornek.com;
location / {
proxy_pass http://127.0.0.1:8000;
include proxy_params;
}
}
- This setting directs incoming requests to the application on port 8000.
Enable configuration:
sudo ln -s /etc/nginx/sites-available/ornek.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
3. HTTPS (SSL) Configuration – Let's Encrypt
- HTTPS is essential for security and SEO.
sudo apt install certbot python3-certbot-nginx
- Get the SSL certificate:
sudo certbot --nginx -d ornek.com -d www.ornek.com
- Certbot adds HTTPS redirect automatically.
4. WebSocket Support (Optional)
- WebSocket configuration for real-time applications:
location /ws/ {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
- This structure transmits WebSocket connections without interruption.
Frequently Asked Questions (FAQ)
1. Why shouldn't I expose the application directly to the internet? Application servers are not optimized for high traffic and attacks.
2. What causes 502 Bad Gateway error? Backend application is not running or the wrong port is used.
3. What happens when the SSL certificate expires? Certbot automatically renews. No manual operation required.
Result
With this guide, you have made your local application servers secure and scalable by configuring Nginx as a reverse proxy. This structure is the basis of modern web architectures.
You can immediately use this architecture on the GenixNode infrastructure for your corporate projects.

