CNAME to wildcard subdomain only getting default server page

cname-recordserveraliasvirtualhostwildcard

We're having problem with a server config, and I hope I can get some help with this as its driving us mad!

Basically, we have an app set up at domain.com, and wildcard subdomains set up on the same domain, for users. We want to implement custom domains for users the same way tumblr does it for instance, so that the user creates a CNAME to his subdomain, for instance :

userdomain.com  -> CNAME -> user.ourapp.com

After setting this up for one user though, his domain just routes to a server default page on our end. After getting in touch with plesk the response was this :

According to internal web servers logics, name based hosting works
using hostname in HTTP header. Using only CNAME record in DNS will not
work, due to DNS return us only new-server IP, and browser will go to
that IP, but an old-server name still remains in HTTP headers.

And web-server after receiving such a request will work as it should,
it will unsuccessfully try to find userdomain.com and open default
virtual host, in our case Media Temple Server page.

Ok, cool. So we went to edit our config slightly. We're running Plesk 10.4, and under the wildcard subdomain we have a httpd.include file for vhosts.

In there we have this :

<VirtualHost 64.207.159.248:80>
    ServerName "_.ourapp.com:80"
    ServerAlias  "*.ourapp.com"
    UseCanonicalName Off

...

Now, we tried removing the ServerName and just keeping the Alias, and using /etc/init.d/httpd reload to reload the config, but we're still getting a Default Server Page.

We're stumped.

Has anyone had experience with this problem before, and is there a solution?

Thanks in advance,
Warren

Best Answer

The browser will still send a Host: userdomain.com header, the CNAME record will not cause a redirect. You will therefore need ServerAlias userdomain.com in your configuration. It is in your application that you will need to associate userdomain.com to the user.

Related Topic