2

I apologize if my description of the problem is unclear. I am working for an online CMS that allows external domains to be used similar to Tumblr or Flavors.me. I noticed both of these services simply require you to add an A record to your domain's DNS.

When trying this, I added an A record for a blank name and "www" both leading to my webserver's IP. While this successfully routes to my server, it doesn't retain the used domain. This leaves me without any idea of what account they're attempting to reach at the application layer. I'm using nginx as my webserver.

I have changed all the nameservers for a domain before, and that works properly, however that causes complications with other issues such as mail and isn't feasible on a scaled solution.

What should I be doing here? Is the A record the correct method of accomplishing this? How are sites like Tumblr and Flavors.me determining which account is being referenced by the domain?

3 Answers 3

1

You most likely only want to have people create an A or CNAME record for a subdomain on their domain that directs to your server IP address (A record) or hostname (CNAME). It isn't necessary to use subdomains, but you need to offer the option.

Your server then serves content based on the request it received, just as you might serve multiple sites from the same server. In Apache you might use separate vhosts or, more likely in your scenario, your CMS serves different content based on the properties of the request. You just need to figure out how the platform your CMS is on can access the different parts of a request, and then pass that to the logic that pulls the content.

If you make your question more specific to include the language/framework/platform the CMS is built in you may get more specific advice. Or try posting to Pro Webmasters or Stack Overflow where you may find people with more specific experience doing this.

2
  • It isn't so much to authenticate their ownership, I want to be able to know the proper behavior when someone uses that specific domain to access their account. Suppose Company XYZ owns xyz.com and they want their employees to be able to see their CMS by using xyz.com. After they modify their DNS to point to my webserver, when the request comes in, how am I to know which account they're attempting to access?
    – Matt
    Feb 7, 2011 at 21:56
  • Ah - I see I misread your question. Updated answer.
    – dunxd
    Feb 7, 2011 at 22:00
0

Short answer: HTTP 1.1 requests must provide the Host: header field (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23).

I expect sites like tumblr are reading this.

1
  • This is very true, but it sounds like he'd be using a browser as his client and are they're any current browsers out there in common use that don't use http 1.1?
    – matthew
    Feb 7, 2011 at 22:35
0

To add to what dunxd said, you also do the A record because that's what directs requests for that (sub)domain to be handled by the service providers servers without the service provider having to take full control of the customers DNS. Once the request come into the service provider, there are several different ways that they can determine which customers data to display.

The first is Virtual Hosts which allow you to set different configurations for each domain you're servicing.

The second is Rewrite Rules which let you determine which data to return based on the requested URL.

The third is to use Server Variables and then use what ever language you're coding the application in to processes requests based on the the http_host value.

These aren't mutually exclusive you can use some combination of them to do what you want.

I'm not sure what you mean by:

it doesn't retain the used domain

Does the URL acctually change in address bar when you visit the domain? If so, you're probably doing an http 301 redirect somewhere. You can still do that, but you would need to have the server rewrite the URL first so that you can still pass the account information.

EDIT: I don't use nginx but I added some links that might be helpful.

2
  • This looks to be hitting close to the issue. I am currently using virtual hosts with nginx as well as rewrite rules. I have a feeling I'm redirecting the url to my root url. The URL actually changes in the address bar. I'll dig into nginx some and see if my configuration is causing some unwanted behavior. Thanks for the lead.
    – Matt
    Feb 7, 2011 at 22:59
  • Maybe look for something like this: if ($host != 'your_domain.com' ) { rewrite ^/(.*)$ your_domain.com/$1 permanent; }
    – matthew
    Feb 8, 2011 at 1:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .