Q: DNS setup: CNAME vs wildcard for SaaS So I'm new to actually caring about how DNS's actually work, as opposed to plugging stuff in and troubleshooting. I have an application that will display different information depending on what domain the user is visiting from. However, I'm not quite sure how it works on my end.
In my head I have two possible solutions:
1. My DNS creates a new CNAME for each instance
2. I keep the DNS simple with a wildcard *.mysite.com
Are both of these ways possible?


*

*Are both of these ways possible?

*Regarding option 2, will I be able to tell what CNAME a user is coming from so I can display the proper information?

*If they are both doable, which one would be better?


My stack is centered on AWS, so I'm using Route 53, and would be using their API if I were to go the 1st option.

A: I'm going to assume this is for a web application, and yes both methods will work.
Lets say you use CNAMES:
sitea.domain.com  CNAME  server.domain.com
siteb.domain.com  CNAME  server.domain.com
server.domain.com  A  1.2.3.4

When you enter sitea.domain.com in a web browser, your dns resolver will try and get the IP address, which based on the CNAME will come back as 1.2.3.4. The browser will then connect to 1.2.3.4 and attempt to retrieve the website sitea.domain.com.
On the web server you can configure different virtual hosts for each domain, or probably more applicable in your case, have one website which handles all requests and use the HTTP_HOST environmental variable to determine which hostname the user entered, and from that display the relevant information.
Wildcards will probably make your application easier as you won't need to add more dns entries every time you want a new hostname. (You could also make the wildcard an A record pointing directly to the IP, not that it makes much difference):
*.domain.com A 1.2.3.4

or
server.domain.com  A  1.2.3.4
*.domain.com  CNAME  server.domain.com

This will function in pretty much exactly the same way - User puts xyz.domain.com in their web browser, it gets resolved to 1.2.3.4, they connect to 1.2.3.4 and request the website for xyz.domain.com
