Plesk for Linux
kb: how-to
ABT: Group B
Applicable to:
- Plesk for Linux
Question
How to create custom Apache2 and Nginx configuration files for all domains?
Answer
Customized configuration files for Apache2 and Nginx could be generated for all domains via changing templates for virtual hosts configuration files.
The procedure is described on this documentation page: Changing Virtual Hosts Settings Using Configuration Templates
Configuration templates structure is described here: Configuration Templates Structure.
Comments
6 comments
Hello
it's very easy to create customized nginx configuration files
But where do we find the variables to use custom PHP settings ?
In file /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
$VAR->domain->physicalHosting->scriptTimeout is value for field max_execution_time
What is $VAR->domain->physicalHosting->??? to use value to field post_max_size or upload_max_filesize ?
Thanks
Hi Raoul STANISLAS,
These 3 settings are set in Plesk > Domains > example.com > PHP Settings.
Also, can be done massively with: How to change PHP settings for one domain or all domain in Plesk using command line?
Hi Francisco Garcia,
No commande line, I want to customize by domain and want to use a value in PHP settings.
I don't want to use a global value like here.
There are no "proxySettings[nginxClientMaxBodySize]" custom field in Plesk > Domains > example.com > Apache & Nginx Settings, so I want to use Plesk > Domains > example.com > PHP Settings > upload_max_filesize in my file /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
Hi Raoul STANISLAS,
One thing is completely different from the other, you're talking about PHP Settings, but then now you talk about Nginx MaxBodySize.
I know one is related to the other, as if one increases, the other should also increase, but are completely different settings.
For Nginx, this might be interesting for you https://support.plesk.com/hc/en-us/articles/213914565
Hello,
after creating custom nginx template I got this error when I want to update/upgrade Plesk from 17.8 to 18 https://support.plesk.com/hc/en-us/articles/115001394613-Plesk-error-Template-processing-failed-TemplateException.
Is there any more elegant solution for custom global nginx configuration?
We need this because we want to block badbots with global nginx.
We just add those directives below in file /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
# Include custom.d/*.conf
include /etc/nginx/custom.d/*.conf;
Regards,
Miha Gregorš vhost templates differs depending on the version, thus it is required to recreate them after upgrade:
1. Move out current templates
2. Perform an upgrade
3. After that you need to recreate custom template taking the new nginxDomainVirtualHost.php from 18 version.
Alternative way is to use fail2ban: it has built in badbots jail, but you may adjust it if you need to ban additional bots.
Please sign in to leave a comment.