Request Entity Too Large and maxMemoryBuffer property doesn’t not work with BodyParser

I’m getting Request Entity Too Large in a POST with multipart/form-data content type request with Lagom 1.4 and Play 2.6 . I have tried in application.conf all this for a BodyParser:

play.http.parser.maxDiskBuffer = 5m
play.http.parser.maxMemoryBuffer = 5m

but still getting the BadRequest.
The strange thing is it works in DEV mode and Prod mode not.

I would be glad to have any support on this.
Thanks

How are you running in production mode? Have you ruled out the possibility of some reverse proxy that runs in front of the service limiting the request size?

We are running in production mode by build a docker image und use a yaml file for the configuration of the statefulset in k8s. We also use a nginx as reverse proxy in front of the service. the max body size is already configured on nginx.
Here the settings for build the docker images:

.settings(
    version := buildVersion,
    version in Docker := buildVersion,
    dockerBaseImage := "openjdk:8-jre-alpine",
    dockerRepository := Some("test"),
    dockerUpdateLatest := true,
    dockerEntrypoint ++= """-Dhttp.address="$(eval "echo $SERVICE_BIND_IP")" -Dhttp.port="$(eval "echo $SERVICE_BIND_PORT")" -Dakka.remote.netty.tcp.hostname="$(eval "echo $AKKA_REMOTING_HOST")" -Dakka.remote.netty.tcp.bind-hostname="$(eval "echo $AKKA_REMOTING_BIND_HOST")" -Dakka.remote.netty.tcp.port="$(eval "echo $AKKA_REMOTING_PORT")" -Dakka.remote.netty.tcp.bind-port="$(eval "echo $AKKA_REMOTING_BIND_PORT")" $(IFS=','; I=0; for NODE in $AKKA_SEED_NODES; do echo "-Dakka.cluster.seed-nodes.$I=akka.tcp://service@$NODE"; I=$(expr $I + 1); done)""".split(" ").toSeq,
    dockerCommands :=
      dockerCommands.value.flatMap {
        case ExecCmd("ENTRYPOINT", args @ _*) => Seq(Cmd("ENTRYPOINT", args.mkString(" ")))
        case c @ Cmd("FROM", _) => Seq(c, ExecCmd("RUN", "/bin/sh", "-c", "apk add --no-cache bash && ln -sf /bin/bash /bin/sh"))
        case v => Seq(v)
      },
    mappings in Universal <++= sourceDirectory map (src => directory(src / "main" / "resources")),
    bashScriptExtraDefines ++= Seq(
      """addJava "-Xms256m"""",
      """addJava "-Xmx512m""""
    ),

here the nginx config for the max body size:

http {
    ...
    client_max_body_size 5M;
    ...
} 

Thanks

Hi @Gesgui,

the build.sbt snippet looks not wrong.

Following on @TimMoore’s train of thought, is it possible the rejection doesn’t happen on the Play HTTP backend but an intermediate proxy (NGinx, HAProxy, k8s Ingress, etc…)?

Related, you mentioned this request works in dev mode but not in production. Please note that some HTTP setting are overridden in dev mode and this could explain the difference in behaviour. Also, keep in mind that in dev mode, if you use port 9000 (service gateway) then you are passing the request through 2 HTTP servers: the service gateway and the actual service.

Cheers,

Hi @TimMoore and hi @ignasi35,

you were right with your assumption regarding the reverse proxy. It was the k8s ingress which was not right configured. It was my mistake.

Thanks for your support.