Webmail not loading after a wildcard subdomain is created

Refers to:

  • Plesk 11.5 for Linux

Created:

2016-11-16 13:14:56 UTC

Modified:

2016-12-21 20:16:59 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Webmail not loading after a wildcard subdomain is created

Symptoms

After creating a wildcard subdomain for a domain, webmail.domain.tld does not load properly.

Cause

When searching for a virtual server by name, if name matches more than one of the specified variants, e.g. both wildcard name and regular expression match, the first matching variant will be chosen, in the following order of precedence:

  • exact name
  • longest wildcard name starting with an asterisk, e.g. “*.domain.tld”
  • longest wildcard name ending with an asterisk, e.g. “mail.*”
  • first matching regular expression (in order of appearance in a configuration file)

Please refer to Nginx server names .

It is software issue PPPM-1316 , which is fixed in Plesk 12.

Resolution

Upgrade to the latest Plesk version.

Workaround

Define exact ' server_name ' for webmail subdomains in custom hosting templates:

  1. Create necessary directories and copy the template files:

    # mkdir /etc/nginx/plesk.conf.d/webmail
    # mkdir /usr/local/psa/admin/conf/templates/custom/
    # cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
    # cp /usr/local/psa/admin/conf/templates/default/nginxWebmailPartial.php /usr/local/psa/admin/conf/templates/custom/nginxWebmailPartial.php
  2. Modify ' /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php ' and ' /usr/local/psa/admin/conf/templates/custom/nginxWebmailPartial.php ' to look as the following:

    # cat /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php | grep -n5 file_put
    server_name ipv4.<?php echo $VAR->domain->asciiName ?>;
    <?php endif ?>
    <?php endif ?>
    <?php
    if (0 == substr_count($VAR->domain->asciiName, '*')) {
    file_put_contents('/etc/nginx/plesk.conf.d/webmail/' . $VAR->domain->asciiName . '.conf','server_name webmail.' . $VAR->domain->asciiName . ';' );
    }
    ?>
    <?php if ($VAR->domain->webAliases): ?>
    # aliases
    <?php foreach ($VAR->domain->webAliases as $alias): ?>

    # cat /usr/local/psa/admin/conf/templates/custom/nginxWebmailPartial.php | grep -n5 include
    <?php /** @var Template_VariableAccessor $VAR */ ?>
    <?php foreach ($VAR->server->ipAddresses->all as $ipAddress): ?>
    server {
    listen <?php echo $ipAddress->escapedAddress . ':' . $OPT['frontendPort'] . ($OPT['ssl'] ? ' ssl' : '') ?>;
    server_name webmail.* roundcube.webmail.* horde.webmail.* atmail.webmail.*;
    include /etc/nginx/plesk.conf.d/webmail/*.conf;
    <?php if ($OPT['ssl']): ?>
    <?php $sslCertificate = $ipAddress->sslCertificate; ?>
    <?php if ($sslCertificate->ce): ?>
    ssl_certificate <?php echo $sslCertificate->ceFilePath ?>;
    ssl_certificate_key <?php echo $sslCertificate->ceFilePath ?>;

If the above steps do not work, then check the webmail config path and include it's exact path into /usr/local/psa/admin/conf/templates/custom/nginxWebmailPartial.php :

  <?php /** @var Template_VariableAccessor $VAR */ ?>
<?php foreach ($VAR->server->ipAddresses->all as $ipAddress): ?>
server {
listen <?php echo $ipAddress->escapedAddress . ':' . $OPT['frontendPort'] . ($OPT['ssl'] ? ' ssl' : '') ?>;
server_name webmail.* roundcube.webmail.* horde.webmail.* atmail.webmail.*;
include /etc/nginx/plesk.conf.d/webmail/*.conf;
<?php if ($OPT['ssl']): ?>
<?php $sslCertificate = $ipAddress->sslCertificate; ?>
<?php if ($sslCertificate->ce): ?>

After the steps above are done, rebuild web configuration with httpdmng utility and disable/enable nginx service:

# /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
# /usr/local/psa/admin/bin/nginxmng -d
# /usr/local/psa/admin/bin/nginxmng -e
Have more questions? Submit a request
Please sign in to leave a comment.