Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to config upload body size restriction in traefik?

Tags:

traefik

I'm using traefik docker image v1.5, and when I try to upload a big file (like 1GB), traefik closes the connection and logs: exceeding the max size 4194304 So is there any way to modify/remove this default restriction?

like image 296
Agas Avatar asked Apr 08 '18 12:04

Agas


1 Answers

Traefik uses a Buffering middleware that gives you control on how you want to read the requests before sending them to services.

With Buffering, Traefik reads the entire request into memory (possibly buffering large requests into disk), and rejects requests that are over a specified limit.

This can help services deal with large data (multipart/form-data for example), and can minimize time spent sending data to a service.

Example configuration:

[backends]
  [backends.backend1]
    [backends.backend1.buffering]
      maxRequestBodyBytes = 10485760  
      memRequestBodyBytes = 2097152  
      maxResponseBodyBytes = 10485760
      memResponseBodyBytes = 2097152
      retryExpression = "IsNetworkError() && Attempts() <= 2"

With the maxRequestBodyBytes option, you can configure the maximum allowed body size for the request (in Bytes).

If the request exceeds the allowed size, it is not forwarded to the service and the client gets a 413 (Request Entity Too Large) response.

https://docs.traefik.io/middlewares/buffering/

like image 124
NicoKowe Avatar answered Sep 17 '22 04:09

NicoKowe