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

reverseproxy: content-length is wrong when the request doesnt fit in the request_buffer #5829

Closed
mcfedr opened this issue Sep 20, 2023 · 0 comments · Fixed by #5830
Closed
Labels
bug 🐞 Something isn't working

Comments

@mcfedr
Copy link
Contributor

mcfedr commented Sep 20, 2023

how to do it

setup a reverse proxy with request_buffers

reverse_proxy example.com {
    request_buffers 1000
}

then send a request bigger than the buffer (i.e. > 1000 bytes in this case)

the content-length header to the backend will be set to 1000, but the body will actually be bigger, its io.MultiReader(buf, originalBody), - so the buffer plus the rest.

different backends have slightly different failure modes for this, im seeing this in my caddy logs

2023/09/20 19:38:08.374	ERROR	http.log.error	net/http: HTTP/1.x transport connection broken: http: ContentLength=1000 with Body length 64301	{"request": {"remote_ip": "127.0.0.1", "remote_port": "55244", "client_ip": "127.0.0.1", "proto": "HTTP/1.1", "method": "POST", "host": "127.0.0.1:8888", "uri": "/anything", "headers": {"User-Agent": ["curl/8.1.2"], "Accept": ["*/*"], "Accept-Encoding": ["deflate, gzip"], "Content-Type": ["text/plain"], "Content-Length": ["64301"]}}, "duration": 0.000745583, "status": 502, "err_id": "150qhej7z", "err_trace": "reverseproxy.statusError (reverseproxy.go:1248)"}

caused by this 2182270 which was fixing #5420

I would just offer a PR with a revert, but not sure how that affects the reason this commit was added

@mcfedr mcfedr changed the title content-length is wrong when the request doesnt fit in the request_buffer reverseproxy: content-length is wrong when the request doesnt fit in the request_buffer Sep 20, 2023
mcfedr added a commit to ekreative/caddy that referenced this issue Sep 20, 2023
@francislavoie francislavoie added the bug 🐞 Something isn't working label Oct 6, 2023
mcfedr added a commit to ekreative/caddy that referenced this issue Oct 11, 2023
mholt pushed a commit that referenced this issue Jan 9, 2024
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
2 participants