Customers who are running SmarterMail for Linux have the option of setting up reverse proxies so they can run SmarterMail on their web server of choice, such as Nginx or Apache. Normally, this doesn't cause any issues for SmarterMail, or for users. However, there may be an instance where some tuning needs to be performed in order to automatically set up SmarterMail accounts in some email clients.
For example, if you find that the account setup is attempting to connect to your root domain (e.g., domain.com) and isn't automatically redirecting to your webmail interface’s hostname (e.g., mail.domain.com). When this happens, chances are the requests are routed to http://domain.com/autodiscover/autodiscover.xml rather than http://MAIL.domain.com/autodiscover/autodiscover.xml.
The solution to this problem is to set up URL Rewriting in your reverse proxy, which is a straightforward process. URL Rewriting should be configured on the server where the root domain is hosted so it can redirect the proper traffic to Smartermail. If your webpage is NOT on the same server as Smartermail, then you’ll likely have to change these configurations to redirect autodiscover requests to your Smartermail server.
Nginx
You’ll need a server block in your Nginx config for the root domain (domain.com). Below is an example of a block for a server that uses domain.com for hosting webpages rather than the web interface:
server {
listen 80;
listen 443 ssl;
server_name _SERVER_NAME_; # REPLACE WITH ROOT DOMAIN (domain.com) ssl_certificate _/PATH/TO/CERTIFICATE_; # REPLACE WITH PATH TO .CRT ssl_certificate_key _/PATH/TO/KEY_; # REPLACE WITH PATH TO .KEY
root /var/www/html; # REPLACE WITH WEB SERVER’s ROOT DIRECTORY
index index.html; # REPLACE WITH WEB SERVER’S MAIN PAGE
location / {
try_files $uri $uri/ =404;
}
# BELOW IS THE REWRITE RULE YOU WANT
location /autodiscover/autodiscover.xml {
rewrite ^/autodiscover/autodiscover.xml$ http://mail.domain.com/autodiscover/autodiscover.xml redirect; }
#—————REPLACE WITH YOUR URL————————
}
Apache
You’ll need 2 virtual hosts in your Apache config for the root domain (domain.com) over ports 80 and 443. Below is an example of hosts for a server that uses domain.com for hosting webpages rather than the web interface:
<VirtualHost *:80>
ServerName domain.com
DocumentRoot /var/www/html
DirectoryIndex index.html
RewriteEngine On
# BELOW IS THE REWRITE RULE YOU WANT
RewriteRule ^/autodiscover/autodiscover.xml$ https://mail.domain.com/autodiscover/autodiscover.xml [R=301,L]
#—————REPLACE WITH YOUR URL————————
</VirtualHost>
<VirtualHost *:443>
ServerName domain.com
DocumentRoot /var/www/html
DirectoryIndex index.html
RewriteEngine On
# BELOW IS THE REWRITE RULE YOU WANT
RewriteRule ^/autodiscover/autodiscover.xml$ https://mail.domain.com/autodiscover/autodiscover.xml [R=301,L]
#—————REPLACE WITH YOUR URL————————
SSLEngine on
SSLCertificateFile /var/lib/smartermail/Certificates/Certs/mail.domin.com.crt SSLCertificateKeyFile /var/lib/smartermail/Certificates/Keys/mail.domain.com.key
</VirtualHost>
Navigate to the following URLs (using your domain and hostnames) to ensure everything is working okay:
https://mail.domain.com/autodiscover/autodiscover.xml (this should already have been working)
https://domain.com/autodiscover/autodiscover.xml (this should redirect to the top one)