• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved nginx - configuration clientmaxbodysize

marcobronx

New Pleskian
Hi ,
I'm at the beginning.
My configuration : plesk onyx v 17.0.17
OS CentOs linux 7.3.1611
I need help to change - client_max_body_size = .... now is 128m I'd like to have 2048m .2gb .
I have panel.ini editor ; I wrote the below script :

cp /usr/local/psa/admin/conf/panel.ini.sample /usr/local/psa/admin/conf/panel.ini
nginxClientMaxBodySize =
plesk sbin httpdmng --reconfigure-all
service nginx restart

and than I wrote in additional directives :

client_max_body_size 2048m;

receiving :

Nginx configuration invalid: nginx: [emerg] "client_max_body_size" directive is duplicate in /var/www/vhosts/system/videosharingchannel.com/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed

can someone help me?
 
You need to remove the entry client_max_body_size for your domain videosharingchannel.com

[EDIT 1]
Above is not true..
By default Plesk has a client_max_body_size 128m; for each vhost.
You can check this by issuing nginx -T
There is a best-practice, but I need to search first.
I can vaguely remember I applied it in the past.

[EDIT 2]
I found this Invalid nginx configuration: nginx: [emerg] "client_max_body_size" directive is duplicate

Which probably is the tutorial you followed.
Check the configuration with "nginx -T | grep client_max_body_size" after you did the "plesk sbin httpdmng --reconfigure-all"

[EDIT 3]

I followed that tutorial and after changing the panel.ini with the specified entry I checked the configs using "nginx -T | grep -B50 client_max_body_size" and I noticed there were still "client_max_body_size 128m;" in each vhost.

They disappeared after I did a "plesk repair web -y -v"

I was able to add a "client_max_body_size 1g;" in the vhost-entry of a certain vhost.

[EDIT 4]
I ran the procedure again on another server doing checks before and after and the "client_max_body_size" directives disappeared out of the vhost-entries after I ran "plesk sbin httpdmng --reconfigure-all". So the procedure described on page Invalid nginx configuration: nginx: [emerg] "client_max_body_size" directive is duplicate worked on that server.


What is not mentioned in that tutorial is that the "client_max_body_size" for all the vhosts missing a custom entry in additional nginx directives will now be 1m instead of the 128m they were before.
This happens because the change in panel.ini causes Plesk to remove all the "client_max_body_size" directives in the individual vhost entries. Because no global entry exists these will revert to the nginx's default of 1MB.

I therefore added a "client_max_body_size 128m;" in my own file /etc/nginx/conf.d/aa400_own_tweaks.conf so this becomes the new server-wide (default) value.



grep 'client_max_body_size' /etc/nginx/conf.d/aa400_own_tweaks.conf
Code:
client_max_body_size 128m;
 
Last edited:
Hello, I've been having this error 413 Request too large for over 5 days now.


1713344513744.png

When I run the command
Bash:
nginx -T | grep client_max_body_size
I get a minimum size of 128mo on everything, but when I make a post request of more than 2mo it doesn't work...




1713344470445.png



I tried to add nginx directives but without success.

1713344604558.png
I don't understand what I'm doing wrong
Thanks to all the people who will give their time to help me.
 
Back
Top