Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an app that sits at exampleapplication.com. It's a rails application sitting on an Apache/Passenger stack.

The app is set up to use subdomain constraints to point to user accounts (e.g. user1.exampleapplication.com).

I want users to be able to point their own domain at their subdomain transparently.

so exampleuser.com points to exampleuser.exampleapplication.com.

I have set up an A record for exampleapplication.com to point to my server. I've set up a DNS zone with A record for exampleuser.com to point to the server.

On which zone to I put the CNAME record?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Not sure exactly what your setup is but you could do this one of two ways. You can certainly create CNAMES for each account but if you know your domain is only going to be used for client accounts simply setup a wildcard CNAME so *.exampleapplication.com then any request, regardless of the subdomain will always point to your application. You app would have to be smart enough to figure out what user is logging in but you get the idea.

Your CNAMEs should always be hosted in your DNS zone. However, I would actually recommend just creating A records for this. So you might have the following:

- A exampleapplication.com       -> 123.123.123.123
- A user1.exampleapplication.com -> 123.123.123.123
- A *.exampleapplication.com     -> 123.123.123.123

It saves on a secondary lookup to resolve the first domain and then resolve the A record for your exampleapplication.com domain as well.

Your clients could then simply create a CNAME in their DNS zone to point to user1.exampleapplication.com.

Hopefully that all makes sense.

share|improve this answer
    
Would you change your recommendation if I told you that I (as in my code) was solely responsible for setting up the DNS zone for the subdomain, AND creating the zone for exampleuser.com. All the zones are in my linode DNS manager. I'm sorry for trying to be vague about the idea (NDA). The users subdomains were used as an example. So just to reiterate when an account is created, my code connects to the Linode DNS API. Creates a zone for the domain my customer provides (and owns) and the records. So if my client enters example1.com, visiting that should show example1.example.com –  Brandon Cordell Aug 21 '12 at 16:16
1  
Not much really changes. The only thing that really changes is that you would then create a DNS entry either CNAME or A, doesn't matter for each customer as you describe. Is there a specific part you are still confused about? –  Brent Pabst Aug 21 '12 at 16:26
    
Where should the CNAME go? In the main zone (example.com) or the customer's domain's zone? –  Brandon Cordell Aug 21 '12 at 16:30
1  
Potentially both. If you want to setup user.exampleapplication.com to point to exampleapplication.com you need to setup a CNAME or A record in your zone. However, if the customer wants to then map theirdomain.com to user.exampleapplication.com they would also need a CNAME. –  Brent Pabst Aug 21 '12 at 16:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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