-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add documentation about request_body directive in Caddyfile #104
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thank you! Just a few minor fixes first.
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
@francislavoie @mholt thanks for the suggestions, I've applied all of them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It occurred to me that we should probably document what happens when more than the maximum body size is read by the server, just for convenience so people don't have to cross-reference the JSON docs. But this LGTM for now, thanks for the contribution!
Please could you tell me what happens? I would expect a BTW, I tried to "cross-reference the JSON docs" but I'm not sure what or where they are. |
@airblade It should depend on the handler that's reading the body, it's the job of the terminating handler to handle errors in a way that is suitable for it.
The "JSON Config Structure" in the docs: https://caddyserver.com/docs/json/ (or the list of config modules: https://caddyserver.com/docs/modules/http.handlers.request_body) |
@mholt Thanks for the response, much appreciated. I've been looking further at the docs and browsing the code but I'm still can't figure out what would happen when a request body exceeds the maximum allowed size. (In my scenario it would be the user uploading a file via an HTML form to Caddy, through to an upstream Puma app server running a Rails app.) |
@airblade Like I said, it depends on the terminating handler and how it chooses to handle the error. Since you mentioned you have an upstream app, I'm going to assume you are using reverse_proxy, which uses a transport module to perform the round trip. The default HTTP transport is implemented by the Go standard library, which controls that part of the logic (reading the request body): |
To clarify - The error will get triggered in whatever subsequent handler which tries to read the body (like Matt said, possibly in From there, Caddy will try to invoke the error handler chain (see https://caddyserver.com/docs/caddyfile/directives/handle_errors) if any is defined. So you get to choose what happens if an error happens. I think you can use an
|
I hadn't thought of that, I suppose that might be possible. Haven't tried it though. |
Actually
YMMV. I haven't tried this. Just a hunch. |
Thank you both for the explanations. I'm not too familiar with Go – sorry for being slow on the uptake. Yes, I'm using {
"level": "error",
"logger": "http.log.error.log0",
"msg": "http: request body too large",
"request": {
"proto": "HTTP/2.0",
"method": "POST",
"headers": {
"Content-Length": [
"150956774"
],
"Content-Type": [
"multipart/form-data; boundary=----WebKitFormBoundaryb8nKVz5ofss7vuyX"
]
},
},
"duration": 5.752661917,
"status": 502,
"err_id": "ijuczeucu",
"err_trace": "reverseproxy.statusError (reverseproxy.go:857)"
} So to convert this into a @mholt This is my first time using Caddy after years of Nginx. It is fantastic and I will not be going back :) |
Yeah, I think that's right. Try adding |
No description provided.