This error often appears when you try to upload a large file. I’ve had it recently in my project and here’s how I solved it.
If you’re using nginx as a reverse proxy, then you should be aware of the fact that there’s a limit to the size of the body in the HTTP requests.
Sometimes it defaults to 2MB, and sometimes it’s even smaller.
In any case, if you’ve already got the error 413 Request Entity Too Large
, this means you either make your request body smaller or simply increase the threshold for the max body size.
Regular nginx installation
If the nginx is installed on your server regularly, then you should edit the configuration file inside the /etc/nginx/conf.d
directory.
Look for the key client_max_body_size
.
If it’s already present, then change its value to something that fits you. For example, client_max_body_size 25m;
will set the max body size limit to 25MB.
Dockerized nginx
If you have the nginx installed as a docker container with something like jwilder/nginx-proxy
, then you’ll need to take a different approach.
List all the volumes bound to your nginx
container and find the one mapped to the /var/lib/docker/volumes/nginx_vhost
directory.
In this volume, you should see a single folder _data
and a file default
inside of it.
Simply add the same line that sets the max body size for the HTTP requests to it and you’ll be good to go:
client_max_body_size 25m;
If the file default
doesn’t exist - go ahead and create it. And if you need a different limit to the max body size, you can change it to your preference as well.
Top comments (0)