[Vagrant] 413 request entity too large for nginx/1.8

If you are using Vagrant and rasmus vagrant box, you may find that you cannot upload a large file (like 200MB) to your local server, result in error:

413 request entity too large  / nginx/1.8

And if you add client_max_body_size 200M; in your /etc/nginx/conf.d/xxxx.conf server context, it does not work.

Increase the value of max_post_size and upload_max_filesize in your php.ini (/etc/php71/php.ini or /etc/php56/php.ini)

post_max_size=200M
upload_max_filesize=200M

did not work.

What works?

  1. Stop the php-fpm service (sudo systemctl stop php-fpm) and nginx service (sudo systemctl stop nginx)
  2. Yes you need to add post_max_size=200M and upload_max_filesize=200M, and also realpath_cache_size=200M in your php.ini
  3. Open /etc/nginx/nginx.conf, inside http{}, add client_max_body_size 200M; (remember to add the semi-colon at the end).
  4. Start the php-fpm service (sudo systemctl start php-fpm) and nginx service (sudo systemctl start nginx) again.
  5. Done!
Hope it helps someone.

Comments

Popular posts from this blog

TCPDF How to show/display Chinese Character?

How to fix fancy box/Easy Fancybox scroll not work in mobile

Wordpress Load balancing: 2 web servers 1 MySQL without any Cloud services