Issue with Akka backend, max length body parser and Apache proxy server

Hi all - I’m using Play 2.8 with the Akka backend and I’ve got an issue with my production site behind an Apache proxy I’m finding tricky to debug.

Basically, I’ve got a POST multipart form with a maxLength body parser limiting size to 5MB. This all works fine in dev mode, returning a 413 status with an appropriate form error.

However, when I put it in production behind Apache (2.4.41) mod_proxy I get an error (“502: Bad Gateway. The proxy server received an invalid response from an upstream server.”)

I can see that Play is correctly rejecting the request, though Apache still uploads the entire file before erroring.

With the Netty backend Apache behaves correctly, returning the 413 error page, although it still uploads the entire file.

Any pointers to resolving this? It’s clearly down to some difference between the Akka and Netty backends but because the error happens on the Apache side I’m struggling to figure out the exact cause or how I can fix it (other than just using Netty.)


To understand what is going on, use tcpflow to sniff the traffic between your apache proxy and your backend.
Do the test with Netty and Akka, you will then be able to compare the HTTP messages exchanged between your proxy and your Java application.

Generally tcpflow is used like this: tcpflow -c -i ens32 port 8080