PortGate

Blueprints · Reverse Proxy & SSL

Beginner 15 min · Caddy

Caddy 2 automatic HTTPS reverse proxy and hardened headers

Lets stock Caddy obtain the certificate, enables HTTP/3, strips the Server header, and proxies to a localhost port. Request rate limits need an extra Caddy module, so they are not in the validated file.

Live config

Baked-in protections

Step 1 · caddy

Caddyfile

/etc/caddy/Caddyfile

Stock Caddy validates this file. Add the caddy-ratelimit module separately if you need a request-rate handler.

{
    servers {
        protocols h1 h2 h3
    }
}

app.example.com {
    header {
        Strict-Transport-Security "max-age=31536000; includeSubDomains"
        X-Frame-Options "DENY"
        X-Content-Type-Options "nosniff"
        Referrer-Policy "strict-origin-when-cross-origin"
        -Server
    }
    reverse_proxy 127.0.0.1:8080
}

Step 2 · bash

Install and reload Caddy

/root/portgate-blueprints/caddy-enable.sh

Uses the distro package when the caddy command is missing.

#!/bin/sh
set -eu
if ! command -v caddy >/dev/null 2>&1; then
  apt-get update
  apt-get install -y caddy
fi
caddy validate --config /etc/caddy/Caddyfile
systemctl enable --now caddy
systemctl reload caddy