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;
}
}