Depending on which web server you use, implement the necessary changes described below to configure your web server’s maximum HTTP request size allowance. By doing so, you can set the threshold file size for which a client is allowed to upload and if that limit is passed, they will receive a 413 request entity too large status.
For Nginx users, the directive which determines what the allowable HTTP request size can be is client_max_body_size. This directive may already be defined in your nginx.conf file located at /etc/nginx/nginx.conf. However, if it isn’t, you can add that directive in either an http, server, or location block and define a value.
The default value for this directive is 1 megabyte (1M). If you do not wish to have a request size limit you can set the value to 0.
Once you have set your desired value, save your changes and reload Nginx by running the following command: service nginx reload.
For Apache web servers there is a similar directive called LimitRequestBody. This directive provides the same functionality as client_max_body_size in that you are able to restrict the size of an HTTP request. The LimitRequestBody directive can be defined in your http.conf file or in an .htaccess file. The default value for this directive in Apache is 0, however, you may set this value to whatever you like (the value is represented in bytes).
For example, if you wanted to restrict requests larger than 100MB you would use the following.
Once you are done making your changes, save the configuration file and reload Apache using the following command: service apache2 reload.