Caddyfile Generator
Modern Cloud Infrastructure & Reverse Proxy

Caddyfile Reverse Proxy & HTTPS Configuration Generator

Generate modern Caddy 2 server configurations with reverse_proxy, automatic HTTPS, compression, security headers, and basicauth.

100% Client-Side Privacy
Zero Server Transmission
Presets:
Profile:
Domain & Virtual HostAuto-HTTPS Ready
TLS / SSL & CertificatesZero-Config ACME
Upstream Backends & Load Balancing1 Nodes
127.0.0.1:3000
Hardening & Performance Toggles
# ========================================================
# Caddy 2 Production Server Configuration
# Site Address: app.example.com, www.app.example.com
# Workload Profile: Current Configuration
# Generated 100% Client-Side Private on ToolsAA
# ========================================================

{
    email [email protected]
    admin off
}

app.example.com, www.app.example.com {
    reverse_proxy 127.0.0.1:3000 {

        # Standard proxy header passthrough
        header_up Host {upstream_hostport}
        header_up X-Real-IP {remote_host}
        header_up X-Forwarded-For {remote_host}
        header_up X-Forwarded-Proto {scheme}

        transport http {
            dial_timeout 5s
            response_header_timeout 60s
        }
    }

    # Ultra-fast high-compression (Zstandard & Gzip)
    encode zstd gzip

    # Security Hardening & Header Manipulation
    header {
        # HTTP Strict Transport Security (HSTS 2-Year Preload)
        Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
        # Prevent MIME-type sniffing attacks
        X-Content-Type-Options "nosniff"
        # Mitigate clickjacking framing attacks
        X-Frame-Options "DENY"
        # Cross-domain referrer policy
        Referrer-Policy "strict-origin-when-cross-origin"
        # Restrict hardware API access
        Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=()"
        # Suppress fingerprinting headers
        -Server
        -X-Powered-By
    }

    # Structured Access Logging
    log {
        output file /var/log/caddy/app.example.com.access.log {
            roll_size 10mb
            roll_keep 5
            roll_keep_for 720h
        }
        format json
    }
}
Domains & Sites
1 Hostname
app.example.com, www.app.example.com
Proxy Upstreams
1 Backend Node Configured
Policy: round_robin
Security & TLS Status
Automatic HTTPS Enabled
HTTP/3 (QUIC) & Zstandard Ready

100% Client-Side Private Generator

Zero server uploads or telemetry. Your server hostnames, internal IP addresses, upstream ports, and credentials are processed strictly in browser memory.

Production Caddy 2 Directives & Automatic HTTPS

Generates modern Caddy v2 configurations with zero-config Let's Encrypt / ZeroSSL TLS certificates, HTTP/3 QUIC, WebSocket multiplexing, and Zstandard compression.

Multi-Platform Deployment Ready

Export verified Caddyfile syntax alongside Docker Compose multi-service definitions, Systemd service files, and terminal validation commands.

Technical Reference & Architecture Guide

Caddyfile Generator — Reference Guide

Developer reference and configuration guide for generating production-ready Caddy web server configurations.

Key Parameters & Controls

domainstring

Primary fully qualified domain name (FQDN) or IP defining the root site address block in the Caddyfile.

Default: example.com
tlsMode"auto" | "internal" | "custom" | "off"

TLS provisioning mode: public ACME automated certificates (auto), local self-signed root CA (internal), explicit PEM certificate and key paths (custom), or plaintext HTTP (off).

Default: auto
upstreamsstring[]

Collection of backend destination addresses or unix domain sockets routed via reverse_proxy.

Default: ["localhost:3000"]
lbPolicy"round_robin" | "least_conn" | "ip_hash" | "first" | "random"

Upstream load balancing algorithm executed by reverse_proxy when distributing requests across targets.

Default: round_robin
enableHealthCheckboolean

Activates active URI probing on backend upstreams to remove failing nodes from active routing tables.

Default: false
enableSecurityHeadersboolean

Applies baseline hardening headers including Strict-Transport-Security, X-Content-Type-Options, and frame controls.

Default: true

Pro Tips & Best Practices

Zero-Downtime Hot Reloads

Never restart the Caddy systemd daemon or container to apply modifications. Use `caddy reload --config /etc/caddy/Caddyfile` to trigger an in-memory dynamic config swap with zero dropped client connections.

Explicit Upstream Timeouts

Production reverse proxies should configure `dial_timeout 5s` and `response_header_timeout 30s` within the `transport http` subdirective to prevent upstream thread exhaustion from lingering hung connections.

ACME Rate Limit Mitigation

During local testing or continuous integration staging, set `tls internal` or use the Let's Encrypt Staging CA directory in global options (`acme_ca https://acme-staging-v02.api.letsencrypt.org/directory`) to avoid production rate limits.

Common Gotchas & Troubleshooting

caddy validate fails with unrecognized directive or invalid nesting

Execute `caddy validate --config /etc/caddy/Caddyfile` to pinpoint the exact failure line. Verify that site blocks have opening braces on the same line as the domain name, and ensure import snippets are declared prior to their usage.

ACME HTTP-01 challenge fails on port 80 with connection refused

Ensure public port 80 is forwarded and permitted through firewall rules (iptables, UFW, or cloud security groups). Caddy requires unencrypted inbound port 80 to satisfy Let's Encrypt and ZeroSSL validation, even when enforcing HTTPS redirects.

reverse_proxy returns HTTP 502 Bad Gateway to incoming clients

Verify whether the upstream backend listens on IPv4 (`127.0.0.1`) rather than IPv6 (`[::1]`). Inside Docker, replace `localhost` with the Docker Compose service name or bridge network IP address to enable cross-container DNS resolution.

Frequently Asked Questions

How does the Caddyfile differ from native Caddy JSON configuration?▼

The Caddyfile is a human-centric domain-specific configuration language parsed and adapted into Caddy's native internal JSON structure at startup. You can inspect the underlying runtime JSON representation by running `caddy adapt --config Caddyfile --pretty`.

Are private keys, passwords, or custom domains sent to an external server?▼

No. The entire generation and validation workflow runs purely in your local browser sandbox. No domains, upstream IPs, basic authentication credentials, or file paths are transmitted or logged externally.

What hashing algorithm is required for the basic_auth directive?▼

Caddy's basic_auth directive requires pre-hashed bcrypt strings for password storage; plaintext passwords will be rejected. Generate valid password hashes in advance using the standard CLI utility `caddy hash-password --plaintext "yourpassword"`.

Can I export configurations directly for Docker Compose and systemd?▼

Yes. The generator includes dedicated export tabs with Docker Compose definitions mounting `./Caddyfile:/etc/caddy/Caddyfile` along with named persistent volumes for `/data` and `/config`, as well as standard systemd unit reload patterns.

Related Tools & Utilities

All Tools →