Symptoms
Cannot set up client_max_body_size
directive in Domains > example.com > Apache & Nginx settings > Additional nginx directives:
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.
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: