nginx - client_max_body_size has no effect

前端 未结 13 1794
无人共我
无人共我 2020-11-28 01:13

nginx keeps saying client intended to send too large body. Googling and RTM pointed me to client_max_body_size. I set it to 200m in th

相关标签:
13条回答
  • 2020-11-28 01:31

    Had the same issue that the client_max_body_size directive was ignored.

    My silly error was, that I put a file inside /etc/nginx/conf.d which did not end with .conf. Nginx will not load these by default.

    0 讨论(0)
  • 2020-11-28 01:35

    Assuming you have already set the client_max_body_size and various PHP settings (upload_max_filesize / post_max_size , etc) in the other answers, then restarted or reloaded NGINX and PHP without any result, run this...

    nginx -T

    This will give you any unresolved errors in your NGINX configs. In my case, I struggled with the 413 error for a whole day before I realized there were some other unresolved SSL errors in the NGINX config (wrong pathing for certs) that needed to be corrected. Once I fixed the unresolved issues I got from 'nginx -T', reloaded NGINX, and EUREKA!! That fixed it.

    0 讨论(0)
  • 2020-11-28 01:36

    Please see if you are setting client_max_body_size directive inside http {} block and not inside location {} block. I have set it inside http{} block and it works

    0 讨论(0)
  • 2020-11-28 01:38

    I meet the same problem, but I found it nothing to do with nginx. I am using nodejs as backend server, use nginx as a reverse proxy, 413 code is triggered by node server. node use koa parse the body. koa limit the urlencoded length.

    formLimit: limit of the urlencoded body. If the body ends up being larger than this limit, a 413 error code is returned. Default is 56kb.

    set formLimit to bigger can solve this problem.

    0 讨论(0)
  • 2020-11-28 01:40

    I'm setting up a dev server to play with that mirrors our outdated live one, I used The Perfect Server - Ubuntu 14.04 (nginx, BIND, MySQL, PHP, Postfix, Dovecot and ISPConfig 3)

    After experiencing the same issue, I came across this post and nothing was working. I changed the value in every recommended file (nginx.conf, ispconfig.vhost, /sites-available/default, etc.)

    Finally, changing client_max_body_size in my /etc/nginx/sites-available/apps.vhost and restarting nginx is what did the trick. Hopefully it helps someone else.

    0 讨论(0)
  • 2020-11-28 01:41

    NGINX large uploads are successfully working on hosted WordPress sites, finally (as per suggestions from nembleton & rjha94)

    I thought it might be helpful for someone, if I added a little clarification to their suggestions. For starters, please be certain you have included your increased upload directive in ALL THREE separate definition blocks (server, location & http). Each should have a separate line entry. The result will like something like this (where the ... reflects other lines in the definition block):

    http {
        ...
        client_max_body_size 200M;
    }    
    

    (in my ISPconfig 3 setup, this block is in the /etc/nginx/nginx.conf file)

    server {
        ...
        client_max_body_size 200M;
    }
    
    location / {
        ...
        client_max_body_size 200M;
    } 
    

    (in my ISPconfig 3 setup, these blocks are in the /etc/nginx/conf.d/default.conf file)

    Also, make certain that your server's php.ini file is consistent with these NGINX settings. In my case, I changed the setting in php.ini's File_Uploads section to read:

    upload_max_filesize = 200M
    

    Note: if you are managing an ISPconfig 3 setup (my setup is on CentOS 6.3, as per The Perfect Server), you will need to manage these entries in several separate files. If your configuration is similar to one in the step-by-step setup, the NGINX conf files you need to modify are located here:

    /etc/nginx/nginx.conf
    /etc/nginx/conf.d/default.conf 
    

    My php.ini file was located here:

    /etc/php.ini
    

    I continued to overlook the http {} block in the nginx.conf file. Apparently, overlooking this had the effect of limiting uploading to the 1M default limit. After making the associated changes, you will also want to be sure to restart your NGINX and PHP FastCGI Process Manager (PHP-FPM) services. On the above configuration, I use the following commands:

    /etc/init.d/nginx restart
    /etc/init.d/php-fpm restart
    
    0 讨论(0)
提交回复
热议问题