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

I am wondering how sites like Google sites and shopify allow customers to create a website and then link it to their own domain?. Google sites allow a user to create their own website, at a user supplied domain, and shopify allows a user to create their own e-commerce site - once again, they can supply their own domain to be used to access the webshop created.

In both cases, the website is ostensibly accesed by typing the users domain name in the browser, although the website is actually being hosted by a third party company (Google, Shopify etc)

How is this possible. Does anyone have an insight into how this is (likely) being done?

share|improve this question

3 Answers 3

up vote 0 down vote accepted

Google asks that you create a CNAME DNS record to point your domain at a host record of theirs.

For instance:

shop.yourdomain.com IN CNAME ghs.google.com

When your browser goes to shop.yourdomain.com, the DNS record redirects your request to the server ghs.google.com. The HOST header in the HTML request says that your browser is requesting shop.yourdomain.com and google's server sees this and points you to the appropriate content.

Shopify will work in much the same way.

share|improve this answer

HTTP 1.0 requests have a Host header, which the browser populates with the actual hostname in the URL, and that the server parses to find out which virtual host should handle the request.

share|improve this answer
    
tx for the answer. This is unlikely to be the correct answer though because it dosen't address several issues like DNS server resolution etc. –  user35402 Jul 11 '10 at 7:55
    
DNS server resolution is trivial. The hostname points to the server's IP address, and there is no limit to the number of hostnames you can point at an address. –  Ignacio Vazquez-Abrams Jul 11 '10 at 8:37
    
Hmm - not so sure. I thought the CNAME records would be the way to implemnt this functionality. Could you explain the precise steps by which a web server on www.example.com can handle requests sent to www.domain1.com and www.domain2.com?. Generating HTML requests with special header information is trivial (speaking as a coder), so what you suggest would suit me better - but I dont see how it would work. For what you propose to work (IIUC), the user will have to manually change their nameservers. Google etc dont require manual intervention. –  user35402 Jul 11 '10 at 9:48
    
There is no such thing as "a web server on www.example.com". There are only web servers bound to IP addresses. Any number of hostnames can be pointed at an IP address. –  Ignacio Vazquez-Abrams Jul 11 '10 at 10:13

It's very simple. The hosting provider sets up an HTTP server running on a given IP address. Let's suppose that's 82.10.11.12.

Our web server can serve requests over HTTP destined for 82.10.11.12. This is governed by DNS. I can have any number of DNS entries (A records) pointing to this IP, eg:

www.mysite.com. IN A 82.10.11.12
anothersite.com. IN A 82.10.11.12
awesomesite.com. IN A 82.10.11.12
rubbishsite.net. IN A 82.10.11.12
etc

If your web browser supports HTTP/1.1, when you connect to this site, the address that you typed into your browser is sent to the web server. This is called a Host Header. The web browser then serves the virtual host matching the name you put in your browser. This is how name-based virtual hosts work.

Note, this is made possible because of HTTP/1.1 not 1.0 as stated in the first answer.

For a very simple overview of HTTP see: http://www.jmarshall.com/easy/http

For more detail, go to the RFCs.

share|improve this answer

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.