Basic Reverse Proxy in Nginx

From the Nginx cheat sheet ยท Reverse Proxy ยท verified Jul 2026

Basic Reverse Proxy

Proxying requests to backend servers

nginx
server {
    listen 80;
    server_name api.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_cache_bypass $http_upgrade;
    }
}
๐Ÿ”„ Forwards requests to backend servers
๐Ÿ“ก Preserves client IP with X-Real-IP header
๐Ÿ”Œ WebSocket support with connection upgrade
โšก Can cache responses for better performance

More Nginx tasks

Back to the full Nginx cheat sheet