Increase request limit

1. The problem I’m having:

I’m currently trying to set up caddy as a reverse proxy for a little personal project, which gives users the ability to upload a photo. The set up is using the latest caddy docker image and a Caddyfile for the config. The default request size seems to max out at around 1MB, which I would like to increase to about 10. The documentation says that this should be possible by using the request_body directive, but that doesn’t seem to work. It keeps returning a 413.

2. Error messages and/or full log output:

{
  "level": "error",
  "ts": 1701203152.9865522,
  "logger": "http.log.access.log0",
  "msg": "handled request",
  "request": {
    "remote_ip": "79.116.32.3",
    "remote_port": "53246",
    "client_ip": "79.116.32.3",
    "proto": "HTTP/2.0",
    "method": "POST",
    "host": "eurovision-dev.delartigue.xyz",
    "uri": "/settings?/updateImg",
    "headers": {
      "User-Agent": [
        "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0"
      ],
      "Referer": [
        "https://eurovision-dev.delartigue.xyz/settings"
      ],
      "Dnt": [
        "1"
      ],
      "Sec-Fetch-Mode": [
        "cors"
      ],
      "Te": [
        "trailers"
      ],
      "Accept": [
        "application/json"
      ],
      "Cookie": [],
      "Accept-Encoding": [
        "gzip, deflate, br"
      ],
      "Sec-Fetch-Site": [
        "same-origin"
      ],
      "Cache-Control": [
        "no-cache"
      ],
      "Accept-Language": [
        "en-US,en;q=0.5"
      ],
      "X-Sveltekit-Action": [
        "true"
      ],
      "Content-Type": [
        "multipart/form-data; boundary=---------------------------16127753568379622463117850286"
      ],
      "Content-Length": [
        "1023930"
      ],
      "Origin": [
        "https://eurovision-dev.delartigue.xyz"
      ],
      "Sec-Fetch-Dest": [
        "empty"
      ],
      "Pragma": [
        "no-cache"
      ]
    },
    "tls": {
      "resumed": false,
      "version": 772,
      "cipher_suite": 4865,
      "proto": "h2",
      "server_name": "eurovision-dev.delartigue.xyz"
    }
  },
  "bytes_read": 33129,
  "user_id": "",
  "duration": 0.065867044,
  "size": 20,
  "status": 413,
  "resp_headers": {
    "Server": [
      "Caddy"
    ],
    "Alt-Svc": [
      "h3=\":443\"; ma=2592000"
    ],
    "Date": [
      "Tue, 28 Nov 2023 20:25:52 GMT"
    ],
    "Content-Length": [
      "20"
    ]
  }
}

3. Caddy version:

Latest available on Docker hub

4. How I installed and ran Caddy:

See docker compose file below

a. System environment:

Docker on Ubuntu

c. compose file:

services:
  caddy:
    image: caddy
    container_name: eurovision-reverse-proxy
    restart: always
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./caddy/data/:/data/
      - ./caddy/config/:/config/
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile

d. My complete Caddy config:

eurovision-dev.delartigue.xyz {
    log {
      level debug
    }

    request_body * {
      max_size 10MB
    }


    reverse_proxy http://eurovision_frontend:3000
    reverse_proxy /api/login http://eurovision_backend:8080
    reverse_proxy /restricted/* http://eurovision_backend:8080
    reverse_proxy /content/* http://eurovision_backend:8080
    reverse_proxy :3306 http://eurovision_db:3306
}

5. Links to relevant resources:

This is the documentation page I have used

Caddy doesn’t have any request limits by default. It must be a limit on your upstream app.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.