Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache multipart POST "pass request body failed"

We are having problems with our web server (which is configured ssl -> apache -> jetty) randomly rejecting multipart upload POST requests with a 400 Bad Request error code. The apache error log (on info level) shows the following two errors:

[info] [client x1.y1.z1.w1] (70007)The timeout specified has expired: SSL input filter read failed.
[error] proxy: pass request body failed to x.y.z.w:8087 from x1.y1.z1.w1
[info] [client x1.y1.z1.w1] Connection closed to child 74 with standard shutdown

or

[info] [client x2.y2.z2.w2] (70014)End of file found: SSL input filter read failed.
[error] proxy: pass request body failed to x.y.z.w:8087 from x2.y2.z2.w2
[info] [client x2.y2.z2.w2] Connection closed to child 209 with standard shutdown

both cases result from the client side in a 400 Bad Request. Sometimes our jetty server doesn't even see the request meaning that it gets rejected on apaches side, sometimes it starts processing it only to be rejected (this manifests itself as a MultipartException in our UploadFilter)

We have mod_proxy setup to use a fallback load balancing scheme but the logs show that a fallback has not yet been triggered causing me to believe this is not the cause of the problem.

I tried setting SetEnv proxy-sendcl 1 but that didn't change anything.

The upload requests are arount 1mb. Only these multipart file POST requests fail, we have multiple GET requests comming in at the same time and they always work as expected.

If anyone can share any advice or suggestions I would be very grateful! Thank you

like image 352
m1h4 Avatar asked Oct 21 '12 23:10

m1h4


2 Answers

You may be seeing this due to timeouts resulting from Apache trying to buffer the entire POST body before passing it through.

Enabling proxy-sendcl may exacerbate this, since this can force Apache to spool a large POST to disk just to calculate the Content-Length when "the original body was sent with chunked encoding (and is large)".

To avoid this, set the environment variable proxy-sendchunked.

like image 157
LBC Avatar answered Oct 11 '22 06:10

LBC


If you are using some ajp-enabled backend server, like Tomcat, you may try using mod_proxy_ajp instead of mod_proxy_http. I had a similar problem on a heavy upload app and I fixed it by changing

ProxyPass /myapp http://localhost:8080/myapp
ProxyPassReverse /myapp http://localhost:8080/myapp

by

ProxyPass /myapp ajp://localhost:8009/myapp
ProxyPassReverse /myapp ajp://localhost:8009/myapp

It's also required to enable the ajp connector on tomcat side, of course.

Hope it helps!

like image 44
BrunoJCM Avatar answered Oct 11 '22 05:10

BrunoJCM