0

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?

user35402
  • 1,171
  • 3
  • 10
  • 18

3 Answers3

1

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.

Ignacio Vazquez-Abrams
  • 45,939
  • 6
  • 79
  • 84
  • 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 07: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 08: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 09: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
0

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.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
upasaka
  • 1,365
  • 9
  • 6
  • how about the SSL, im trying for eg. Create a CNAME shop.mycustomerdomain.com to shop.mydomain.com - it words well, but the SSL shows in red as invalid as issued to mydomain.com... how shopify handles this – Raja Khoury May 04 '18 at 09:55
0

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.

Justin Higgins
  • 610
  • 5
  • 12