Applicable to:
- Plesk for Linux
Symptoms
Cannot set up client_max_body_size
directive in Domains > example.com > Apache & Nginx settings > Additional nginx directives:
PLESK_ERROR: Invalid nginx configuration: nginx: [emerg] "client_max_body_size" directive is duplicate in /var/www/vhosts/system/example.com/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed
Cause
This is Plesk bug with ID #PPPM-1914 which will be fixed in future product updates.
the corresponding user story https://jira.plesk.ru/browse/PPP-56191
Resolution
By default, Plesk applies 'client_max_body_size 128m;'
directive for each domain, while the default server-wide value is '1m'
. The following steps keep '128m'
as default value server-wide and apply custom value on domain level:
- Connect to Plesk server using SSH as root user
- Set up global value for nginx (
'128m'
or any other default server-wide value can be set up here):
# echo 'client_max_body_size 128m;' > /etc/nginx/conf.d/aa_client_max_body.conf
-
Modify /
usr/local/psa/admin/conf/panel.ini
:# echo -e "[webserver]\n nginxClientMaxBodySize =\n" >> /usr/local/psa/admin/conf/panel.ini
If the
panel.ini
file does not exist, create it using sample file and set correct permissions:# cp /usr/local/psa/admin/conf/panel.ini.sample /usr/local/psa/admin/conf/panel.ini
# chmod 644 /usr/local/psa/admin/conf/panel.ini
-
Regenerate Apache configuration files:
# plesk sbin httpdmng --reconfigure-all
-
Restart nginx:
# service nginx restart
Video tutorial:
Comments
28 comments
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.
Hi, thank you for the comment. The article has been updated.
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.
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
@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)
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
@frater, if add
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:
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 "c
lient_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.
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".
@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.
Note to self: notice the two different variable names: client_max_body_size in nginx conf and nginxClientMaxBodySize in Plesk ini.
@adrianTNT, yes, indeed client_max_body_size is for Nginx and nginxClientMaxBodySize is for Plesk panel.ini.
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.
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.
When will this be fixed?
I got same errors today.
No Chance.
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.
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":
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.
Any update on an ETA for a fix? this has been an issue for the last 3!? years.
Come on guys, fix this! this solution it is not working
Stavros Tsalikoglou
Explain what you think that is broken.
This solution is working, you're probably not understanding it.
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!
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:
Else, the client_max_body_size will work, but the limited temporary file size will still prohibit processing of some large files.
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.
Please fix this bug ... three years has been enought of waiting :D
nice using the code above broke my site.
2022, seven years, still not solved.
But many thanks for spoon-feeding us a solution. Worked like a charm.
Something went wrong: a bug was discovered in 2017 and was still not fixed in 2022.
Please sign in to leave a comment.