Thursday, July 27, 2017

Is there a better way to redirect my client's domains?



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?


Answer



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.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...