logo
Limiting Request Body / File Upload Size in Caddy

Limiting Request Body / File Upload Size in Caddy

Dec 23, 2025


Limiting Request Body / File Upload Size in Caddy

By default, Caddy does not restrict request body size. You can easily enforce limits to prevent large file uploads or abuse.

This is especially important for:

  • File upload endpoints

  • APIs

  • Protecting server memory and disk


Limit Maximum Request Size for a Domain

Example: Limit uploads to 10 MB.

example.com {
    request_body {
        max_size 10MB
    }

    reverse_proxy localhost:3000
}

Any request exceeding this size will be rejected automatically.


Different Limits for Different Routes

Example:

  • /upload → max 5 MB

  • Everything else → no limit

example.com {

    handle_path /upload/* {
        request_body {
            max_size 5MB
        }
        reverse_proxy localhost:3000
    }

    handle {
        reverse_proxy localhost:3000
    }
}

This is ideal for APIs where only specific endpoints accept files.