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.

How to create custom Apache and nginx configuration files for all domains in Plesk

Follow

Comments

6 comments

  • Avatar
    Raoul STANISLAS

    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

    <?php if (!empty($VAR->domain->physicalHosting->proxySettings['nginxClientMaxBodySize'])): ?>
    client_max_body_size <?php echo $VAR->domain->physicalHosting->proxySettings['nginxClientMaxBodySize'] ?>;
    <?php endif ?>

    <?php if ($VAR->domain->physicalHosting->scriptTimeout): ?>
    proxy_read_timeout <?php echo min($VAR->domain->physicalHosting->scriptTimeout, 2147483) ?>;
    <?php endif ?>


    $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

     

     

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

    0
    Comment actions Permalink
  • Avatar
    Raoul STANISLAS

    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

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

    0
    Comment actions Permalink
  • Avatar
    Miha Gregorš

    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,

     

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov

    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.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request