Nginx - 413 Request Entity Too Large

Nginx - 413 Request Entity Too Large

Hello,

I have the following problem when using Nginx webserver:

When uploading a slightly larger file via Nginx (probably> 1MB), I was surprised at the 413 Request Entity Too Large error.

With Nginx I don't know much yet, I did the installation according to the local instructions:
https://cloud.up4.cz/poradna/486-linux-instalace-a-nastaveni-nginx-php-a-mysql-lemp

Can anyone advise me what to do? Thank you

REPLY


Hello,

for Nginx, increase client_max_body_size to 100 MB, for example:

Nginx - globally


- vim /etc/nginx/nginx.conf
- in block http add
client_max_body_size 100M;


Nginx - only for the given virtualhost


- vim /etc/nginx/sites-available/host.conf
- in block location add
client_max_body_size 100M;


Reload Nginx:
systemctl reload nginx

REPLY


Thank you very much for your quick response!

I raised client_max_body_size for Nginx, but I encountered another problem:

When uploading a upload via PHP Nette, when the upload is larger than 1 MB, I get an error:

0 => "An error occurred during file upload." (37)

- if I upload under 1MB, it will pass

Do you know what else it can upset? Thank you

REPLY


Hello,

in addition to Nginx, you will also need to adjust the upload limits in php.ini.

PHP - change upload limits



1.) Find out used php.ini = create file vim /var/www/html/index.php
< ?php phpinfo() ? >

And look at the output of this file - looking for the word php.ini :-)


2.) Edit the given php.ini = eg vim /etc/php/7.2/fpm/php.ini
+ 30-user.ini = vim /etc/php/7.2/fpm/conf.d/30-user.ini

post_max_size = 100M
upload_max_filesize = 100M


#restart php fpm and nginx
systemctl restart php7.2-fpm
systemctl reload nginx


PS: For php CLI we find php.ini with the command php --ini , for nginx php -r 'phpinfo();' | grep php.ini

Komentáře

Vaše reakce na Nginx - 413 Request Entity Too Large

Související obsah

linux

bash

terminal

webserver

nginx

Reference

Podívejte se na naše reference

Prohlédnout

Aplikace

Podívejte se na naše aplikace

Prohlédnout

Co umíme?

Podívejte se co umíme

Prohlédnout

Co umíme?

Vytváříme sofistikované aplikace pro náročné

Od webových aplikací přes android až po převodové můstky či složité informační systémy.

Podívejte se k nám

Máte ještě čas? Podívejte se na další rubriky

Tento web používá soubory cookie. Dalším procházením tohoto webu vyjadřujete souhlas s jejich používáním.. Více informací zde.