Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceeding request_body's max_size returns 502 Bad Gateway #5652

Closed
tribut opened this issue Jul 25, 2023 · 2 comments
Closed

Exceeding request_body's max_size returns 502 Bad Gateway #5652

tribut opened this issue Jul 25, 2023 · 2 comments
Assignees
Labels
bug 🐞 Something isn't working
Milestone

Comments

@tribut
Copy link

tribut commented Jul 25, 2023

This appears to be a regression from #4558, setting max_size causes a 502 error with this configuration when a large file is uploaded:

http:// {
	request_body {
		max_size 20MB
	}

	handle_path /api/* {
		reverse_proxy api:80
	}
}

I'm using Caddy 2.6.4 (from Docker Hub).

Log entry:

{
  "level": "error",
  "ts": 1690267490.8453255,
  "logger": "http.log.error",
  "msg": "readfrom tcp 172.120.4.5:53858->172.120.4.3:80: {id=tzchyd2sh} requestbody.errorWrapper.Read (requestbody.go:63): HTTP 413: http: request body too large",
  "request": {
    "remote_ip": "172.120.4.1",
    "remote_port": "43776",
    "proto": "HTTP/1.1",
    "method": "POST",
    "host": "localhost:1080",
    "uri": "/api/upload/",
    "headers": {
      "Referer": [
        "http://localhost:1080/test"
      ],
      "Sec-Fetch-Dest": [
        "empty"
      ],
      "Accept-Encoding": [
        "gzip, deflate, br"
      ],
      "Sec-Fetch-Site": [
        "same-origin"
      ],
      "Dnt": [
        "1"
      ],
      "Accept": [
        "*/*"
      ],
      "Content-Type": [
        "multipart/form-data; boundary=---------------------------26304888236811446562077596232"
      ],
      "User-Agent": [
        "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0"
      ],
      "Content-Length": [
        "24670389"
      ],
      "Cookie": [],
      "Sec-Fetch-Mode": [
        "cors"
      ],
      "Origin": [
        "http://localhost:1080"
      ],
      "Connection": [
        "keep-alive"
      ],
      "Pragma": [
        "no-cache"
      ],
      "Accept-Language": [
        "de-DE,de;q=0.8,en-US;q=0.5,en;q=0.3"
      ],
      "Cache-Control": [
        "no-cache"
      ]
    }
  },
  "duration": 0.060551495,
  "status": 502,
  "err_id": "nt27mkz4e",
  "err_trace": "reverseproxy.statusError (reverseproxy.go:1299)"
}
@mholt
Copy link
Member

mholt commented Jul 25, 2023

(Deleted my previous comment as I was mobile at the time and didn't see the full log)

@mholt mholt added the bug 🐞 Something isn't working label Jul 25, 2023
@mholt mholt self-assigned this Jul 25, 2023
@mholt mholt added this to the v2.7.0 milestone Jul 25, 2023
@mholt mholt closed this as completed in 18c309b Jul 25, 2023
@mholt
Copy link
Member

mholt commented Jul 25, 2023

Thanks for the report! In my experiments, the patch above fixed it. Feel free to verify if you please 😃

My config file:

:8080 {
	request_body {
		max_size 10
	}
	reverse_proxy localhost:1234
}

:1234 {
	respond {http.request.body}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants