Skip to main content
⚑ OpenDevDocs
DevOps & Deployment
devopsnginxRecipeIntermediate

Nginx Reverse Proxy with Certbot Let's Encrypt SSL

Configure an Nginx reverse proxy on Ubuntu with automated SSL/TLS certificates and HTTP to HTTPS redirection.

Verified: 2026-09-30
Tested on:ubuntu 24.04, nginx 1.24+
Platforms:
linux
#nginx#ssl#certbot#reverse-proxy#devops#linux

Goal

Forward incoming public HTTPS web traffic on ports 80/443 to an internal Node.js or Docker application listening on port 3000, with automated Let's Encrypt SSL certificates.


Prerequisites

  • Ubuntu 22.04 or 24.04 VPS
  • Registered domain name with an A record pointing to the server's public IP address
  • Backend application running locally (e.g. port 3000)

```nginx
server {
    server_name docs.example.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;

        # WebSocket and Connection headers
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';

        # Client identity headers
        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;
    }
}
```
# Verify configuration syntax
sudo nginx -t

# Reload Nginx
sudo systemctl reload nginx
```
```bash
sudo certbot --nginx -d docs.example.com --non-interactive --agree-tos -m admin@example.com --redirect
```

Automated Renewal Verification

Certbot automatically installs a systemd timer for certificate renewal. Verify renewal works cleanly:

sudo certbot renew --dry-run

On this page