Plesk, Wildcard DNS and Webmail

If you have a Virtual Private Server [VPS] on a CentOS and use Plesk as a control panel and want to add Wildard “*” DNS entry while still maintaining webmail.domain.com, then you have come to the right place.

Throughout the steps, replace domain.com with your actual domain name.

When you add ServerAlias *.domain.com to the vhost.conf file, the already working webmail.domain.com will no longer work, as the wildcard will catch that.

How to add Wildcard “*” DNS entry

In your domain, select DNS Settings

Click Add Record

Select CNAME for Record Type; put * into domain name and domain.com for the canonical name. [You may use A record type too]

Login to PowerPanel [Parallels Power Panel] as root

- click File Manager
- go to / var/ www/ vhosts/ domain.com/ conf/
- there you’ll find httpd.include do not edit this. This is automatically updated by Plesk.
- create/update another file vhost.conf
- enter only

ServerAlias *.domain.com

- do not enter <VirtualHost inside the file.  this file will be included inside httpd.include.  So that syntax already exists.

To run commands, you can use SSH Client. In PowerPanel, click “SSH Connection” and Login.

- after the creation of vhost.conf file, we need to run the update. run the following. If no error message is displayed, then all is good.

- # /usr/local/psa/admin/bin/websrvmng -av

- whether the vhost.conf was new or not, you will need to reload the Apache configuration:

- # /etc/init.d/httpd reload

If you want, you can restart Apache using the command:

- # /sbin/service httpd restart

Now you have added the Wildcard “*” DNS Entry in both DNS Settings and vhost.conf. Let’s make sure AtMail is working.

How to make AtMail working even after adding Wildcard “*” DNS entry

Click File Manager

- go to / etc/ httpd/ conf.d/

You’ll see a file called

zz_atmail_vhost.conf

This is the AtMail configuration file. Because the filename starts with “zz” it is at the bottom of sort order. It is this order Apache processes the configuration. So we need to put this file just above zz010_psa_httpd.conf [in your server, you may not find exactly this file. You should find something similar to this name].

So I just renamed our zz_atmail_vhost.conf to zz001_atmail_vhost.conf
This put the file just above our zz010_psa_httpd.conf [note: I tried putting atmail_vhost.conf, which put it at the top, but that made viewing received emails impossible]

Now you need to restart qmail.
You can restart qmail using Plesk under Server -> Service Management. You can use ’service qmail restart’ on CentOS.

Even after this, if you still not able to view received emails, just restart your container [PowerPanel].

This is not necessary but you can rebuild Qmail configuration files using /usr/local/psa/admin/sbin/mchk utility.

Test:

check webmail.domain.com is working [make sure sending, receiving and able to read received emails working]
check your wildcard dns working [that is your dynamic subdomains you may already have working]
check any domain alias you may have working.
check your main domain.com working

Thanks to:

http://forum.parallels.com/showthread.php?t=91870

http://rackerhacker.com/2007/08/10/using-wildcard-subdomains-in-plesk/

http://kb.parallels.com/en/1380

http://forum.parallels.com/showthread.php?t=74996