Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Technology Foundations DNS Basics A Records

Jibril Abdul
Jibril Abdul
16,535 Points

Is this how wix and wordpress offer "free" domains like (jibril.wix.com)?

Also, if all of the domain names for the A Records that were created point to the same IP address then does that mean that they all deliver the same content?

So relating to my first question would jibril.wix.com and rachel.wix.com both contain the same content if they both resolved to the same IP address?

1 Answer

It's very possible (and common) to serve multiple sites from a single server via what Apache calls 'virtual hosts'. Basically, the web server software (like Apache or Nginx) chooses the correct site to serve via the hostname being requested.

A simple example using Nginx's server blocks could look something like this:

server {
  listen 80;
  server_name site1.com www.site1.com;
  root /path/to/site1;
}

server {
  listen 80;
  server_name site2.com www.site2.com;
  root /path/to/site2;
}

Nginx would choose the appropriate site to serve based on the hostname of the request.

So, is that how Wix/Wordpress/whoever does it? Maybe, but it's probably more likely they have a more complicated system because of the scale they operate at. This is definitely one of the simplest ways to go about it, and the most appropriate for small scale stuff, or situations where you aren't frequently adding or removing virtual hosts.

Jibril Abdul
Jibril Abdul
16,535 Points

Thanks for the response Nate! A lot of useful information!