• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue Problem with vhost / redirect all Subdomains

daanse

Regular Pleskian
Hi,
i want every Domain on the Server i.e.:

autoconfig.<customerdomain>.de to be automatically apply to my Plesks Hostname httpdocs Folder.

Example Code which i played arround with.
Code:
<VirtualHost *:80> #Must be the first Virtual host
    ServerAdmin [email protected]
    ServerName www
    DocumentRoot /var/www/html
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^autoconfig\. [NC]
    RewriteRule ^/(.*)    http://autoconfig.hoster.com/$1 [L,R=301,NE]
        #...
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot /var/www/html/autoconfig/
    ServerName autoconfig.hoster.com
    <Directory /var/www/autoconfig>
     Order allow,deny
    allow from all
    </Directory>
</VirtualHost>

where do i have to place this?
/etc/apache2/sites-enabled/ i already createt here a new conf but didn't took affect.
then i changed and added the Code into "@000-default.conf" but no changes.

Any advice how to not manually edit every customer Domain to get redirected to one URL?
 
Yea just for Thunderbird.
Everything else not working correct.
Theres an APP "AutoMX" which can be used, but still .... seems not easy.

I inserted Code to "/etc/apache2/sites-enabled/000-default.conf" and it seems to work.

Till need something better here
 
Hi ChrisH,

the equivalent folder "/etc/apache2" on Ubuntu/Debian - based - systems, is located at:
Code:
/etc/httpd/
on CentOS/RHEL - based systems.
 
This is an edited part of a working config.
It works for both Thunderbird and Outlook.

No existing configs needs to be edited, so Plesk is unable to mess with it.
Plesk will be totally unaware of it.
It merely adds an additional config file in /etc/nginx/conf.d/

Outlook is a bit more difficult as it is https, but I took that hurdle as well.
Because I have a wildcard (*.wolf.com) and it works with an SRV-record I can tell the autodiscovery process to look for a subdomain in my own domain wolf.com.
This (wolf.com) will also help nginx to pick the right config for the Microsoft autodiscovery.
This is easier for Thunderbird's autoconfig as it is a subdomain starting with "^autoconfig".

You only need the 1st CNAME if you are only doing Thunderbird's autoconfig.
But I would do the whole thing and also solve the certificate problem for your mail clients.

Each domain has a CNAME and an SRV-record in their own zone.
It needs a "helper CNAME" in the zone of the provider.

CNAME
autoconfig.client.com. IN CNAME mail.client.com.

SRV-Record
_autodiscover._tcp.client.com. IN SRV 0 1 443 client-com.wolf.com.

In the provider's zone you need a "helper" CNAME pointing to the correct server.
This will also be the hostname that will be used in your mail client.
It therefore also solves the "certificate problem" which we now have with our mail clients.

A domain with "client.com" will use the hostname "client-com.wolf.com" in their mail clients.

CNAME
client-com.wolf.com. IN CNAME mail.client.com.

I have a cronjob creating/removing those DNS-records.
I don't think I'm going to share those as they are quite specific to my environment.
It would work to add these domains manually and/or put them in a DNS-template.

The 2 PHP-scripts that provide the xml's for Thunderbird & Outlook will make that translation automatically based on the hostname that's connecting.

I was very proud after creating this system solving both the certificate problem and the autodiscovery.

cat /etc/nginx/conf.d/zz095_autodiscover.conf
Code:
server {
    listen 1.2.3.4:80;
    server_name ~^autoconfig\.[a-z0-9-]+\.[a-z0-9-]+$;

    root  /var/www/autoconfig_autodiscover;

    index index.html;
    error_log /var/log/nginx/autoconfig_autodiscover/error.log;
    access_log /var/log/nginx/autoconfig_autodiscover/access.log combined;

    location ~* /mail/config-v1.1.xml {
      try_files $uri /config-v1.1.xml.php?$args;
      rewrite ^(.+)$ /config-v1.1.xml.php?$1 last;
    }

   location ~ /config-v1\.1\.xml\.php$ {
     try_files $uri =404;
     include /etc/nginx/fastcgi_params;
     fastcgi_pass 127.0.0.1:9000;
     fastcgi_index index.php;
     fastcgi_param SERVER_FQDN  $host;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_param PATH_INFO $fastcgi_script_name;
     fastcgi_intercept_errors on;
   }
}


server {
    listen 1.2.3.4:443 ssl http2;
    server_name ~^[a-z0-9-]+[a-z0-9]-[a-z0-9]+\.wolf.com$;
    root  /var/www/autoconfig_autodiscover;

    error_log /var/log/nginx/autoconfig_autodiscover/error.log;
    access_log /var/log/nginx/autoconfig_autodiscover/access.log combined;

    ssl_certificate             /root/.ssh/wildcard.wolf.com.pem;
    ssl_certificate_key         /root/.ssh/wildcard.wolf.com.key;

    ssl_stapling on;
    ssl_stapling_verify on;

    add_header          Strict-Transport-Security       "max-age=15768000; preload" always;
    add_header          Referrer-Policy                 strict-origin-when-cross-origin always;
    add_header          X-Frame-Options                 SAMEORIGIN always;
    add_header          X-XSS-Protection                "1; mode=block" always;
    add_header          X-Content-Type-Options          nosniff always;

    ssl_dhparam         /etc/dhparam/dhparam4096.pem;
    ssl_session_timeout 5m;

    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

    client_max_body_size 1m;

    index index.php index.html index.htm;

    location ~* /autodiscover/autodiscover.xml {
      try_files $uri /autodiscover.xml.php?$args;
      rewrite ^(.+)$ /autodiscover.xml.php?$1 last;
    }

   location ~ /autodiscover\.xml\.php$ {
     try_files $uri =404;
     include /etc/nginx/fastcgi_params;
     fastcgi_pass 127.0.0.1:9000;
     fastcgi_index index.php;
     fastcgi_param SERVER_FQDN  $host;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_param PATH_INFO $fastcgi_script_name;
     fastcgi_intercept_errors on;
    }
}
 
Last edited:
Back
Top