{
    admin off
    auto_https off
    servers {
        # The proxy connects from loopback and sets X-Forwarded-For.
        trusted_proxies static 127.0.0.1/32 ::1/128
        client_ip_headers X-Forwarded-For
    }
}
http://:8788 {
    bind 127.0.0.1
    root * /mnt/hdd/localsr-downloads/public
    @write not method GET HEAD
    respond @write 405
    @hidden path_regexp hidden (^|/)\.
    respond @hidden 404
    @incomplete path *.partial *.tmp
    respond @incomplete 404
    header {
        -Server
        X-Content-Type-Options nosniff
        Referrer-Policy no-referrer
    }
    @immutable path /releases/*
    header @immutable Cache-Control "public, max-age=31536000, immutable"

    # Counting endpoints: the request itself is the count (see localsr-stats).
    @count path /hit /ping/update-check
    header @count Cache-Control no-store
    respond @count 204

    # Only counted paths leave Caddy, and only to the loopback collector.
    # No access log is written to disk.
    @uncounted not path /hit /ping/update-check /releases/*
    log_skip @uncounted
    log {
        output net 127.0.0.1:8791 {
            dial_timeout 1s
            soft_start
        }
        format json
    }

    file_server
    handle_errors {
        header Cache-Control no-store
        respond "{err.status_text}" {err.status_code}
    }
}
