What Happens When You Request A Website In Your Browser?

  • Sep 16, 2019
  • 0
  • by Ryan Flowers

It’s a great question that deserves an answer. In this blog post, we’re going to give a high level overview of this process, and look at what it takes to turn a URL request into a website in your browser. We’ll also explore some basic terminology along the way.

For the sake of discussion, we’re going to assume a very common setup: A standard domain such as “a2hosting.com” with a Linux/cPanel based web hosting account such as our own Swift plan. Let’s get started!

First Step: DNS Lookup

When you direct your browser to a2hosting.com, the first thing that happens is that your computer does what’s called a DNS lookup. DNS is what translates a friendly name like “a2hosting.com” into something the computer can use: an IP address.

DNS lookups aren’t simple, but the process itself is. The browser first asks your computer for the information. The computer in turn asks your internet service provider (ISP), who in turn asks the Root DNS servers for the whole world. The Root DNS servers refer the lookup to the registry for .com (since we’re asking for a2hosting.com), who in turn refers the lookup to the place where the domain was purchased: The registrar.

We told the registrar to look at A2’s DNS servers for the info, and now the chain is complete: The browser asks A2’s DNS servers “Hey, what’s the IP for a2hosting.com?” The DNS server answers, and the next steps happen. 

 For the sake of the discussion, we’ll use the IP 10.20.30.40. 

Second Step: TCP/IP & Apache

The browser then opens a connection to 10.20.30.40 and sends a request for the website via the Transmission Control Protocol. Together, these make up TCP/IP. 

On the server side, there is software that serves websites, and it’s always listening for requests. A common piece of software is called “Apache”. Apache is configured to listen for connections on a given IP address on port 80. Just as a building with a single street address can have dozens of doors, an IP can have thousands of ports. There one specific “door” that’s labeled “Websites: Enter Here”, and that’s port 80. 

Apache hears the browser’s call: “Hey are you, listening at 10.20.30.40 on port 80? Give me a2hosting.com!”

Third Step: Your Website is Served, Sir!

The problem that could come up is that there might be hundreds of websites that use 10.20.30.40. How does Apache know which one to give to the browser? The answer lays in the request itself. 

The web browser has supplied three things: 

  • IP (10.20.30.40)
  • Port (80)
  • Domain Name (a2hosting.com)

Apache has a configuration file that contains all of this information. This file essentially says “If a2hosting.com on 10.20.30.40 port 80 is requested, send these files.” This type of configuration is called a “Virtual Host” . A Virtual Host is defined by a bit of text inside Apache’s main configuration file. It contains those three pieces of information (domain, IP, port), and also the location of the website files called the DocumentRoot. A Virtual Host in Apache’s  configuration file will look similar to the following:

<VirtualHost 10.20.30.40:80>

ServerName a2hosting.com

DocumentRoot /home/a2hosting/public_html

</VirtualHost>

From there, the web server says to the browser “Okay browser, here’s the information you asked for!” and the website loads up on your computer. 

Is That it?

There are deeper levels of knowledge and understanding to be had, but this covers the basics. It’s easy to see that if any information between the request and the configuration don’t match, a website won’t work as expected.  There are a lot of steps in making a website request happen. It’s not extremely complicated; there are just a lot of steps. 

We hope this has lifted the veil from the process and some of the technology under the hood here at A2 Hosting. Thanks for reading!

The A2 Posting

  • Popular
  • Recent
  • Categories
  • Tags