I serve multiple websites for my clients on one server. During development I simply make a subdomain on my own domain. Example client.mydomain.example. Often my customers already have a domain and email with another provider. I do not want to host email for my clients.

I have tried three different ways of setting up DNS:

  1. Make an HTTP redirect from clientdomain.example to www.clientdomain.example and then a CNAME record for www.clientdomain.exmple to point to temporary subdomain on my server client.mydomain.example.
  2. Have an A record from (*.)clientdomain.tld to my server IP, but leaving MX and such to point to their current email-host.
  3. Set up my own nameservers and use those for my client's domain. Then setup the same way as 2.

As far as I can see there are pros and cons with all three:

  1. Pros: Convenient. I can change the IP address on my server, move to another serverpark, set up failsafe, load balancing and so on.
    Cons: I force my clients to use www, and if they already have a site on non-www they might suffer SEO-vise(?). Also the extra CNAME record is bad for page speed.
  2. Pros: No SEO or page-speed issues. Easy setup.
    Cons: If I need to change IP, I need to make DNS changes for ALL my client sites.
  3. Pros: No SEO or page-speed issues. If I need to change server, I can do this for all my client sites at once, since DNS settings is conveniently setup on my own name servers.
    Cons: I need to run my own name servers. I also have to set up MX records and possibly other DNS records for my customers.

My preferred way right now is 1. since I think the pros outweighs the cons for most of my cases.

Are there any other way to redirect from a domain to a server without specifying the IP-address?

Clarification: Solution 1 works for me, but it is slower because of the two steps before coming to the final A record. Ideally I would want to point both non-www and www to my server domain, but as far as I know, this is not possible with a CNAME record, right?

  • I don't understand the problem. Can you please try editing your post to make it clear the problem you're trying to solve. DNS is usually pretty simple. – Tim Mar 4 '18 at 7:21
  • Why would you redirect anyone to your development server at all? Those should only be accessible by people who develop the website, which should at least be smart enough to type in a correct url themselves... – Anubioz Mar 4 '18 at 7:37
  • @tim I added clarification – OnklMaps Mar 4 '18 at 7:52
  • I still don't understand the question. You've said you've tried three ways of doing something, but haven't said what that something is. Are you trying to set up production DNS to point at your sever? Development subdomain? Is it another server? Really unclear. – Tim Mar 4 '18 at 8:01
  • 1
    The CNAME, as all other DNS related stuff will be cached and have mostly no influence on the global performance of your website. – Patrick Mevzek Mar 4 '18 at 19:26

Please notice, that a CNAME is not a HTTP redirect at all.

  • Only redirect here is from the example.com to www.example.com and it can be made permanent. The extra CNAME is on DNS level and will be cached, so it doesn't really affect the site performance nor speed at all.

  • Your web server needs to be aware of the client domain despite who's hosting the DNS.

That's why I'd prefer your case #1, with a better understanding:

  1. Guide your client to add www.example.com. CNAME client.example.net. to be able to change the IP address on your own, if necessary.
  2. Advise how to make a redirect from non-www to www on their current web server.
  3. Bind the actual domain name to your client.example.net in your webserver's configuration.

With the case #3 you won't just end up technically hosting DNS servers, but also be responsible of doing updates whenever a client needs a new third party record.

  • What about the non-www to www, that's a HTTP redirect, right? So that can possibly affect performance some milliseconds? Also, this "www-redirect" that most domain providers have, that is based on some rewrite rule in a .htaccess file? – OnklMaps Mar 4 '18 at 15:34

So if I understood correctly what you want to do is to have the ability after the development phase to simply point a cname to your server (client.mydomain.tld) and handle the rest on your own server.

What I tried on my Setup right now with Cloudflare for managing my DNS entrys is to just put two cname records one www.client.tld and one client.tld. After that you can Handle the request on your Server and just rewrite the URL to the specific needs.

I would also choose your option number one since it's the easiest to handle.

And I also found some Information about the use of CNAME records here: Should CNAME Be Used For Subdomains?

  • You understood correctly. But how did you cname from client.tld? I thought that was not possible? – OnklMaps Mar 4 '18 at 15:36
  • @OnklMaps you are right you can not put a CNAME at apex of a zone, since it already has at least NS records there, and CNAME can not cohabit with any other record types. – Patrick Mevzek Mar 4 '18 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.