0

As discussed in many threads, I have set

client_max_body_size 2M;

in my /etc/nginx/nginx.conf

and

client_max_body_size 100M;

in one of my virtual hosts config.

And it works, as in the upload of files >2MB fails on virtual hosts than don't have the 100M directive.

The problem is that this is not reported by PHP applications, like WordPress. They still show a 100MB limit. And when someone tried to upload something >2MB, they see:

Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.

Is there a way to communicate the "true" max filesize limit to PHP applications, even if it's set at the webserver level?

MultiformeIngegno
  • 1,687
  • 9
  • 26
  • 31

1 Answers1

1

WordPress, like most PHP scripts, didn't use nginx configuration's client_max_body_size, rather they used PHP's upload_max_filesize and post_max_size.

You can try to change this, but if you do so, you may need to have two php-fpm service running rather than one, reading different php.ini file, to have multiple upload_max_filesize configurations.

PS: Sorry about bad PHP manual links, if you used their correct fragment identifier, they tend to be covered by their header. Try to scroll up on this post-max-size fragment.

mforsetti
  • 2,666
  • 2
  • 16
  • 20