Invalid nginx configuration: nginx: [emerg] "client_max_body_size" directive is duplicate

Follow

Comments

10 comments

  • Avatar
    adrianTNT

    Please edit documentation to say "edit or create panel.ini file".

    I avoided creating this file because when I seen it doesn't exist I thought this is an old solution. 

     

  • Avatar
    Nikolay Zhmuk

    Hi, thank you for the comment. The article has been updated.

  • Avatar
    Tony Collins

    This does not work. This workaround does not set the correct variable for the correct template. A Plesk expert responded to someone discussing this workaround in another thread by saying "it's the setting for the Plesk Panel server (sw-cp-server), not the server that the domains are hosted on Apache or Nginx". In other words, the advice given here does not do anything for the problem we are facing, because it deals with the PLESK PANEL SERVER, not the nginx web server!

    The bug still exists, and this workaround should be deleted and a proper workaround written. It's 2017 - why is a 2 year old bug still not resolved properly? I've just installed a new instance of Plesk and I couldn't believe the problem is still there.

    As it stands, users have to copy a template file using the instructions at https://docs.plesk.com/en-US/onyx/advanced-administration-guide-linux/virtual-hosts-configuration/changing-virtual-hosts-settings-using-configuration-templates.68693/

    PLEASE DELETE THIS POST - it WILL NOT solve the problem because Plesk nginx templates do NOT take their information from panel.ini! It has wasted my time and caused frustration - and you'll see from other forum posts that other users have had exactly the same waste of time from following these instructions.

  • Avatar
    Del Corso (Edited )

    I'm assuming that you're editing client_max_body_size so you can accept the upload of large files. So, aside from the usual apache and php settings you also have to edit something else. 

    As an example, if attempting to upload a 134MB file in your error logs you'll get something like this:

    [Tue Jun 06 19:06:11.237658 2017] [fcgid:warn] [pid 30592:tid 140115808524032] [client 64.1.1.1:47758] mod_fcgid: HTTP request length 134222462 (so far) exceeds MaxRequestLen (134217728), referer: http://foo.bar/upload.php

    So, under Additional Apache Directives in your Plesk domain make sure to add this, for 512MB:

    FcgidMaxRequestLen 512000000

  • Avatar
    Robert Asilbekov

    @Tony Collins  you are not quite correct. The resolution is for customer's websites nginx, not for sw-cp-server (Plesk). So if you still experience the error consider to review your custom templates. As the solution in the article works fine and can be verified by executing "nginx -T" (it will dump running configuration)

     

  • Avatar
    frater

    This workaround works, but it should be noted that the domains without any specific entry will now have a body_size of only 1 MB. This is the default value of Nginx.

    To resolve that you can create a new global entry of 128 MB by placing this value in a file in /etc/nginx/conf.d/

     

    grep 'client_max_body_size' /etc/nginx/conf.d/aa400_own_tweaks.conf

    client_max_body_size 128m;
  • Avatar
    Bulat Tsydenov

    @frater, if add 

    [webserver]
    nginxClientMaxBodySize = 64m

    to '/usr/local/psa/admin/conf/panel.ini' configuration file and reconfigure all domains, this value will be applied for all the domains. You can check it:

    # grep client_max_body_size /var/www/vhosts/system/example.com/conf/nginx.conf
    client_max_body_size 64m;
    client_max_body_size 64m;

     

  • Avatar
    frater (Edited )

    The Tutorial on which I was commenting doesn't say "nginxClientMaxBodySize = 64m"
    This working tutorial says "nginxClientMaxBodySize ="
    This is entirely different.

    What you propose is exactly what people coming to this page DO NOT want.
    It creates a "client_max_body_size 64m;" in each host (something you already found out as it seems).

    This makes it impossible to change that to another value for a particular host.
    Your proposed change will only change the 128m to a 64m value. The problem they had will stay.
    BTW.... It's not clear to me if you want to correct my post or you have a problem implementing this tutorial. If it's the latter then I found the reason; You need to lose the "64m".

    What "those people" want and what this tutorial offers is the removal of "client_max_body_size" in each host.
    This makes it possible to create a custom value in certain vhosts using the "Additional nginx directives"

    What this tutorial DOES NOT cover is a solution for the body size of the vhosts that have no custom value. While Plesk made sure each vhost had a body size of 128m, this isn't anymore after applying the tutorial.

    So, this tutorial will solve the original problem, but by doing so it also creates a new problem. vhosts without an entry in "Additional nginx directives" will get a body size of 1m (this is Nginx's default). 

    By adding this value (128m) for that directive in the file /etc/nginx/conf.d/aa400_own_tweaks.conf, you will make up for that. That will become the new default value for Nginx as it's placed outside of the vhosts.

  • Avatar
    frater

    The author of the tutorial wrote this additional sentence:

    "If the value is specified in panel.ini (e.g. "nginxClientMaxBodySize = 64m") default client_max_body_size value will be overridden server-wide."

    It has nothing to do with the scope of this article and is even confusing for people that do not read the article with care.
    I think it's best to just remove that sentence.
    The sentence is also ambiguous as "server-wide" should really be "for all vhosts".

  • Avatar
    Bulat Tsydenov

    @frater Thank you for such detailed response and for taking part in improving our Knowledge Base! I got your points and I agree with them, the article was updated accordingly.

Please sign in to leave a comment.