Mail autodiscover with NGINX not working

1 post / 0 new
#1 Mon, 04/02/2018 - 11:28
HSG

Mail autodiscover with NGINX not working

I've recently setup Virtualmin with NGINX (I have some NGINX experience, and none with Apache) on Ubuntu 16.04 mostly for hosting some email domains, but I seem to be having a problem with email autodiscovery.

Email autoconfiguration has been enabled but when testing it with Outlook and Thunderbird autoconfigure is not working. Specifically autoconfigure.xml cannot be found (404 http code). Most of the documentation I have been able to find is related to Apache, which has been unhelpful. I believe the default NGINX configuration needs to be modified to redirect the request to autodiscover.mydomain.tld/autodiscover/autodiscover.xml to autodiscover.cgi in the cgi-bin folder, but I have no idea where to start with that.

My NGINX configuration is the default for a blank website with the exception of all http requests being redirected to https as follows:

server {
listen 80;
listen [::]:80;
return 301 https://$host$request_uri;
}

server {
server_name mydomain.tld www.mydomain.tld;
listen <my-ip>:443 ssl;
root /home/mydomain/public_html;
index index.html index.htm index.php;
access_log /var/log/virtualmin/mydomain.tld_access_log;
error_log /var/log/virtualmin/mydomain.tld_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/mydomain/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/php-nginx/151913637110794.sock/socket;
}
ssl_certificate /home/mydomain/ssl.combined;
ssl_certificate_key /home/mydomain/ssl.key;
ssl on;
}