Skip to content
runonprem

Config generators

Nginx & Caddy reverse proxy config generator

Put a self-hosted app behind a domain with HTTPS. Generate a reverse-proxy config for Nginx (with Let’s Encrypt certificates from certbot) or Caddy (automatic HTTPS), including WebSockets, upload limits and an optional HSTS header.

MB

/etc/nginx/conf.d/app.example.com.conf

server {
    listen 80;
    listen [::]:80;
    server_name app.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name app.example.com;

    # Certificates from certbot (Let's Encrypt): certbot certonly --nginx -d app.example.com
    ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;
    client_max_body_size 100m;

    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;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 3600s;
    }
}

Test with nginx -t, then reload with systemctl reload nginx.

How to use it

  1. Point the domain’s DNS record at your server and open ports 80 and 443.
  2. Enter the domain and the address the app listens on (e.g. 127.0.0.1:8080, or a container name on a shared Docker network).
  3. Nginx: obtain the certificate first (certbot certonly --nginx -d your.domain), then add the config. Caddy fetches certificates by itself.
  4. Turn on HSTS only after HTTPS works, because browsers remember it.

Formula and method

Nginx:  server :80 → 301 to https;  server :443 ssl → proxy_pass http://upstream
        headers: Host, X-Real-IP, X-Forwarded-For, X-Forwarded-Proto
        WebSocket: proxy_http_version 1.1 + Upgrade/Connection headers
Caddy:  domain { reverse_proxy upstream }   # HTTPS + WebSockets built in

Worked example

app.example.com {
    request_body {
        max_size 100MB
    }
    reverse_proxy 127.0.0.1:8080
}

FAQ

Nginx or Caddy?

Caddy is the quickest way to HTTPS with a few lines of config. Nginx is everywhere, very configurable and well documented. Both handle homelab traffic easily.

Why do uploads fail with 413?

413 Request Entity Too Large comes from the proxy’s body size limit (Nginx defaults to 1 MB). Raise the max upload size for apps like Nextcloud, Immich or Paperless.

Do I need WebSocket support?

Many dashboards and apps (Home Assistant, Uptime Kuma, Proxmox console, chat apps) use WebSockets. Leaving it on does no harm for apps that do not.

Related tools

Formulas reviewed November 27, 2026 by Novian · runs entirely in your browser · methodology