1. Caddy version (caddy version
): v2.2.0
2. How I run Caddy:
a. System environment:
b. Command:
paste command here
c. Service/unit/compose file:
paste full file contents here
d. My complete Caddyfile or JSON config:
[
{
"handler": "custom_hadnler"
},
{
"handler": "reverse_proxy",
"transport": {
"dial_timeout": "10s",
"expect_continue_timeout": "20s",
"keep_alive": {
"enabled": true,
"idle_timeout": "60s",
"max_idle_conns": 100,
"max_idle_conns_per_host": 20
},
"max_response_header_size": 4096,
"protocol": "http",
"read_buffer_size": 4194304,
"response_header_timeout": "20s",
"write_buffer_size": 4194304
},
"upstreams": [{
"dial": "xxx:80"
}]
}
]
3. The problem I’m having:
reverse_proxy return the following error log:
{
"level": "debug",
"ts": "2020-10-05 10:15:06.384",
"logger": "http.handlers.reverse_proxy",
"msg": "upstream roundtrip",
"upstream": "xxx:80",
"request": {
"remote_addr": "[::1]:55080",
"proto": "HTTP/1.1",
"method": "POST",
"host": "xxx",
"uri": "/xxxxxx"
"headers": {
"User-Agent": [
"curl/7.54.0"
],
"Content-Type": [
"application/x-www-form-urlencoded"
],
"X-Forwarded-Proto": [
"http"
],
"X-Forwarded-For": [
"::1"
],
"Accept": [
"*/*"
],
"Postman-Token": [
"04763d08-d8ff-43ed-8d84-30d8d37b1aa2"
],
"Cache-Control": [
"no-cache"
],
"Content-Length": [
"79"
]
}
},
"duration": 0.052033278,
"error": "net/http: HTTP/1.x transport connection broken: http: ContentLength=79 with Body length 0"
}
4. Error messages and/or full log output:
5. What I already tried:
The problem occurs for the following conditions:
- the request with header: application/x-www-form-urlencoded
- If the previous custom_handler did the ParseForm
then the reverse_proxy got this error, the reason should be the previous custom handler have read the body in the form format, so the reverse_proxy read the 0 length body.
In some scenarios, the previous handlers will do some work and need the form value, so is it possible for reverse_proxy to handle this special case?