Articles in this section

Cannot apply Apache & nginx configuration on Plesk with Premium Email extension installed: "server" directive is not allowed here

Plesk for Linux kb: technical kolab

Symptoms

  • Plesk Premuim Email extension by Kolab is installed and enabled.

  • The following error is displayed when trying to apply the configuration at Domains > example.com > Apache & nginx page:

    PLESK_ERROR: Invalid nginx configuration: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/plesk.conf.d/vhosts/example.com.conf:31 nginx: configuration file /etc/nginx/nginx.conf test failed
    Unable to use the current nginx configuration file and to rollback to the previous version of the file because they both contain invalid configuration.

Cause

Plesk Premuim Email extension provides invalid mail autodiscovery section to templates during building Nginx virtual host configuration files.

This is extension bug with ID PPPM-14026.

Resolution

Until the bug is fixed, apply the next workaround:

Debian-based OS (Debian, Ubuntu)
  1. Connect to the server via SSH.

  2. Backup original /opt/psa/admin/plib/Template/Processor.php file:

    # cp -a /opt/psa/admin/plib/Template/Processor.php{,.bak}

  3. Download custom fixed file:

    # curl -LO https://support.plesk.com/hc/en-us/article_attachments/15329755898519/Processor.php

  4. Replace the original file:

    # mv -f ./Processor.php /opt/psa/admin/plib/Template/Processor.php

RHEL-based OS (centOS, AlmaLinux, CloudLinux)
  1. Connect to the server via SSH.

  2. Backup original /usr/local/psa/admin/plib/Template/Processor.php file:

    # cp -a /usr/local/psa/admin/plib/Template/Processor.php{,.bak}

  3. Download custom fixed file:

    # curl -LO https://support.plesk.com/hc/en-us/article_attachments/15329755898519/Processor.php

  4. Replace the original file:

    # mv -f ./Processor.php /usr/local/psa/admin/plib/Template/Processor.php

Workaround I
  1. Go to Domains > example.com > Hosting & DNS > Hosting and switch the preferred domain to None.
  2. Press OK to save changes.
Workaround II

Note: this workaround only for cases when the extension is activated for all domains.

  1. Create a custom nginx configuration template, for example on Debian/Ubuntu server:

    # cp /opt/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /opt/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php

  2. Add <?php echo "}" ?> to the custom template in the mail autodiscovery section, so that this:

    CONFIG_TEXT: <?php if ($VAR->domain->isMailAutodiscoveryEnabled): ?>
    <?php echo $VAR->includeTemplate('domain/service/nginxMailAutoConfig.php') ?>
    <?php endif ?>

    turns into this:

    CONFIG_TEXT: <?php if ($VAR->domain->isMailAutodiscoveryEnabled): ?>
    <?php echo $VAR->includeTemplate('domain/service/nginxMailAutoConfig.php') ?>
    <?php echo "}" ?>
    <?php endif ?>

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.