2

Lets say I have top domain

domain-X.com with DNS A record pointing it to IP 1.2.3.4

then I have domains, which I might not have control over, they belong to customers, which owns them and may have different providers etc.

domain-A.com, domain-B.com, domain-C.com

and I want these three domains to also point to IP 1.2.3.4 but I don't want to set the DNS A-record for each domain to numeric IP, but rather somehow to point them to "the IP of domain-X.com" ... is this possible?

It needs to work so that the application on domain-X.com knows from which URL (domain) the request originated (domain-A.com) and also the user should still see domain-A.com/something NOT domain-X.com/something in the browser.

Is this possible? If not, what other solutions are there? The problem is that there might be more domains then 3 and I want to point them to one IP address where web application serving these domains will be. The application needs to know the origin URL of request. But when the IP changes (because for example I will have to move the app from one VPS of one ISP to another ISP etc), then it could be very problematic to change DNS records in all these domains...

Thanks for any tips and help.

EDIT: Suggested answers to set CNAME domain-A to domain-X are not correct answers, because CNAME record can't be set to top domain (only sub domain) without problems. See CNAME for top of domain?

EDIT2: The links to possible duplicates are also not helpful as they assumes that I am in control of the DNS records of all domain-a/b/c/etc domains. In fact each domain may be owned by different client/customer with different provider. All I want is to make it easy to point to my IP where my webapp is running, and avoid problems in the future when/if I would have to move my webapp to different hosting etc. Then changing all the DNS records could be problematic...

I just discovered that something like "Virtual IP" exists. Could this help?

Another idea coming to my mind is... to solve this from different angle.. what strategies are there to have one IP for very long time?

  • You're the only new user I've ever seen to ask this question and research the apex CNAME problem. That alone is worth an upvote. I'm flagging this as a dupe of another question since my answer would basically be the same. (it's either that, or use the DNS providers who provide custom solutions to the apex CNAME problem; fake records such as ALIAS, ANAME, and Cloudflare's "CNAME flattening" which aren't really CNAMEs) – Andrew B Jul 20 '15 at 22:37
  • possible duplicate of Apex ANAME / ALIAS record in Windows Server 2012 R2 DNS Manager – Andrew B Jul 20 '15 at 22:39
  • possible duplicate of How can I manage all of my domains with minimal configuration? – HBruijn Jul 21 '15 at 6:27
  • The possible duplicates assumes I am in control over dns records or that it is all on one server. It is not this case. see edit in my question. – urza.cc Jul 21 '15 at 16:13
0

EDIT: This answer might not be valid.

Add a CNAME record like this:

domain-A.com CNAME domain-X.com

This means that during domain name resolution, the client first resolves domain-A.com, DNS server then notices it is a CNAME record for domain-X.com and returns the IP address of domain-X.com.

So, the client gets the IP address and still shows domain-A.com in the address field.

The web server has to be configured either so that it has a separate virtual host for each domain, or no virtual hosts that match domain names.

  • 2
    Is this really possible? It seems that CNAME records can only be set to subdomains, but NOT for top domain. – urza.cc Jul 20 '15 at 9:44
  • Good point, I didn't realize the root domain / subdomain difference here. – Tero Kilkanen Jul 20 '15 at 10:49
  • Correct, apex CNAME (as defined by RFC, not Cloudflare) is not valid. – Andrew B Jul 20 '15 at 22:43
0

EDIT: As you warned us, due to RFC1912 : "A CNAME record is not allowed to coexist with any other data". That's why I'm gonna change my answer.

I don't want to set the DNS A-record for each domain to numeric IP, but rather somehow to point them to "the IP of domain-X.com" ... is this possible?

1) If it is not a problem for you, create a dedicated subdomain for your app and point it to domain-x.com.

domain-x.com.  IN A      1.2.3.4
app.domain-a.com.  IN CNAME  domain-x.com.

2) Some DNS Service providers permit to perform this trick on domains, check thoses answers, there is a list.

The user should still see domain-A.com/something NOT domain-X.com/something in the browser

If you're not performing a HTTP redirection, it will be fine.

The application needs to know the origin URL of request.

It depends of how you're setting it up, but the original host is in the header of the HTTP request.

  • 2
    Is this really possible? It seems that CNAME records can only be set to subdomains, but NOT for top domain. – urza.cc Jul 20 '15 at 9:45
  • Yes, you can set a CNAME to an external domain. – Nabil Bourenane Jul 20 '15 at 10:34
  • 2
    CNAME to external domain is not problem. Problem is CNAME for top domain instead of subdomain only (i.e. set CNAME for domain-a.com rather then www.domain-a.com) The W3C states it violates RFC1034 and some DNS providers dont offer the option to set CNAME for the "root" domain.. – urza.cc Jul 20 '15 at 10:44
  • 1
  • Ok, then why don't you use a subdomain "app.domain-x.com" or a wildcard in your CNAME statement "*.domain-x.com" ? – Nabil Bourenane Jul 20 '15 at 11:22

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.