S
S
Svetlana Okuneva2019-12-23 15:34:22
PHP
Svetlana Okuneva, 2019-12-23 15:34:22

How to configure Nginx + php to correct "413 Request Entity Too Large" error?

I do all this in docker
Roughly speaking, I indicated in php.ini

post_max_size = 1M
upload_max_filesize = 1M

in nginx-local.conf
client_max_body_size 2m;
Miscellaneous - no error. These are experiments)
As a result, when the file is larger than specified in nginx, I get an error in nginx
<html>
    <head>
        <title>413 Request Entity Too Large</title>
    </head>
    <body>
        <center>
            <h1>413 Request Entity Too Large</h1>
        </center>
        <hr>
        <center>nginx/1.17.5</center>
    </body>
</html>

And I want php error
What to do with it? Only specify some very large size in nginx like 1G
and in php.ini - real limits - like 20MB or is there another way?
Docker, nginx, php - everything is restarted and checked - the settings have been tried on.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladislav, 2019-12-23
@Jewish_Cat

Well, first there is an appeal to nginx. It processes the incoming request and looks through its filters. Therefore, if you upload more than the allowed file, then at first nginx will give an error, and this file (or whatever you upload there) will not reach php. Nginx is a proxy server (roughly speaking)
I advise you not to put 1GB in nginx, otherwise it will be bad.

A
Anton B, 2019-12-23
@bigton

See the NGINX proxy_intercept_errors setting

I
Igor, 2019-12-23
@IgorPI

server {
    ...
    client_max_body_size 32m;
    ...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question