On October 19, 2021, we have enabled single-sign-on for our Plesk Support Center to provide a seamless login/account experience. This implies that you’ll be able to use a single account across any of our web-facing properties.
If you had already registered your account at MyPlesk.com/Plesk360/Platform360 please use one for login. Otherwise please re-register it using the same email address as your existing Zendesk login (support account). It’s essential that you use the same email address on our support center to ensure that your tickets stay attached to the same account.

Cannot set up client_max_body_size for nginx in Plesk: [emerg] "client_max_body_size" directive is duplicate

Follow

Comments

25 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. 

     

    1
    Comment actions Permalink
  • Avatar
    Nikolay Zhmuk

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

    1
    Comment actions Permalink
  • 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.

    0
    Comment actions Permalink
  • 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

    0
    Comment actions Permalink
  • 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)

     

    0
    Comment actions Permalink
  • 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;
    0
    Comment actions Permalink
  • 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;

     

    0
    Comment actions Permalink
  • 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.

    0
    Comment actions Permalink
  • 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".

    0
    Comment actions Permalink
  • 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.

    0
    Comment actions Permalink
  • Avatar
    adrianTNT (Edited )

    Note to self: notice the two different variable names: client_max_body_size in nginx conf and nginxClientMaxBodySize in Plesk ini.

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    @adrianTNT, yes, indeed client_max_body_size is for Nginx and nginxClientMaxBodySize is for Plesk panel.ini.

    0
    Comment actions Permalink
  • Avatar
    Daniel

    Sadly, this article is not helpful at all!

    I've applied the above solution to two independent Plesk Onyx servers with the newest updates installed and yet it wouldn't let me save the setting in the Nginx settings. Sadly, the only working solution is removal of Nginx extension at the moment. I suggest everyone not to waste time with the above solution as it does not work on a fresh install.

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello @Daniel, I have checked the instruction on Plesk Onyx 17.8.11 Update #11 and CentOS 7.4.1708. After doing all the steps I have managed to specify client_max_body_size in additional Nginx directives.

    Please, let me know the exact Plesk version (17.0/17.5/17.8) and the OS version and what exact error message is displayed.

    0
    Comment actions Permalink
  • Avatar
    Lenor

    When will this be fixed? 

    I got same errors today. 

    No Chance. 

    0
    Comment actions Permalink
  • Avatar
    Anzhelika Khapaknysh

    Hi @Lenor,

    Currently, there is no ETA regarding the fix.
    So I'd recommend applying the workaround suggested.

    Feel free to follow this article to be updated once the bug is fixed.

    0
    Comment actions Permalink
  • Avatar
    Ops-team

    As in nginx.conf there is this line:

    http {
    include mime.types;
    default_type application/octet-stream;

    proxy_read_timeout 180;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
    client_max_body_size 128m; <==

    ... .. .

    You can exlude the first step

    # echo 'client_max_body_size 128m;' > /etc/nginx/conf.d/aa_client_max_body.conf

    and do only the modification in "panel.ini":

    [webserver]
    nginxClientMaxBodySize =
    0
    Comment actions Permalink
  • Avatar
    Vladimir Chernikov

    Hello @Ops-team,

    Thank you for sharing your experience!

    The step is required to keep 128m as default value for the client_max_body_size directive server-wide. By default server-wide value is 1m.

    0
    Comment actions Permalink
  • Avatar
    tech nucleus

    Any update on an ETA for a fix? this has been an issue for the last 3!? years.

    1
    Comment actions Permalink
  • Avatar
    Stavros T

    Come on guys, fix this! this solution it is not working

    1
    Comment actions Permalink
  • Avatar
    frater

    Stavros T

    Explain what you think that is broken.

    This solution is working, you're probably not understanding it.

    -1
    Comment actions Permalink
  • Avatar
    Stavros T

    frater

    maybe or maybe not. 

    I did all these steps, and gives me a duplication error in the Regenerate step. 

    The reconfiguration cannot complete

    To not be able to add different directive in every domain at nginx is weird.

    This is an problem first stated in 2017, so I must say again, come on guys.. fix this!

    2
    Comment actions Permalink
  • Avatar
    Peter Debik

    The solution provided is basically correct, but it is missing a part that prohibits some large downloads:

    In the Nginx "additional directives" of an individual website or in the /etc/nginx/conf.d/aa_client_max_body.conf general server file that applies to all webites, add this directive:

    proxy_max_temp_file_size 0;

    Else, the client_max_body_size will work, but the limited temporary file size will still prohibit processing of some large files.

    0
    Comment actions Permalink
  • Avatar
    Robert Asilbekov

    Peter Debik, thank you for the feedback. The directive could be helpful for some particular cases. But, it is out of the case covered in the article.  

    == https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_max_temp_file_size
    When buffering of responses from the proxied server is enabled, and the whole response does not fit into the buffers set by the proxy_buffer_size and proxy_buffers directives, a part of the response can be saved to a temporary file. This directive sets the maximum size of the temporary file. The size of data written to the temporary file at a time is set by the proxy_temp_file_write_size directive.
    The zero value disables buffering of responses to temporary files.
    ==

     

    0
    Comment actions Permalink
  • Avatar
    Peter (Edited )

    Please fix this bug ... three years has been enought of waiting :D

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request