What happens when you type https://www.google.com in your browser and press Enter
Published: 2023-11-16 10:48:12


- If you have watched any heist movie then you know, the wonder always comes from the behind-the-scenes events; all the detailed machinations set in place by the group of thieves that are played out in a grand reveal as every part of their plan falls into place just so.
- When a user types in the URL into any browser of their choice, it takes seconds at most to receive results, the highest of which are the most accurate.
- However, there are a lot of components in play under the hood communicating to allow the user access to the website as well as allowing them to interact with said website. This article aims to explain the processes that occur after pressing Enter.

## Domain Name System (DNS)

- Google.com is a lot easier to remember than a unique set of characters assigned to google’s domain name.
- The DNS performs the conversion of the domain name typed into the browser into an IP address i.e., the digital equivalent of a postal address which identifies devices across the internet.
- The client computer performs the series of steps below to get ahold of the required IP  address.
- The diagram below depicts the communication that occurs when the client computer submits a DNS query to find the matching IP address to the domain name entered by the user.

- For each step in the diagram, the handover is performed if the current component does not contain the matching IP address.


![DNS Query Process](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ta5wnnw7rz7gvd7ivyqk.png)
## Component Key

1. Hosts file & Cache: this is a temporary storage for previously visited IP address that allows the client computer to quickly access the requested website.
2.  DNS Resolver: acts as an intermediary between the client computer and the other DNS servers
3. Root Name Server: main reference in the DNS hierarchy; provides directions to the correct TLD nameserver.
4. TLD Name server: stores information about domain names i.e. the last section of a domain name such as .com; for google.com the .com TLD name server leads to the location of the matching IP address in the final server; authoritative nameserver
5. Authoritative Name server: contains information related to domain names

## TCP/IP (Transmission Control Protocol/Internet Protocol)

- This refers to a suite of communications protocols used to interconnect network devices on the internet or any private network.
- Computers use agreed-upon sets of rules i.e., protocols to communicate; when the same protocol is used, communication between devices is seamless, as opposed to the chaos that would occur if multiple protocols are used simultaneously.
- Earlier on in the article, we touched on IP addresses and the part they play in allowing devices across the internet to communicate, TCP is the postman to IP’s postal address that enables the recipient to receive mail or the sender to send mail.
- Information cannot be sent in one go using the above protocols, as this leads to potential loss of certain sections, therefore TCP/IP divides messages into packets to be sent separately and reassembled on the receiving end.

## TCP/IP Layers

- There are 4 layers involved in this process as explained below

1. Data Link layer: deals with the physical aspect of sending the packers i.e., media such as Ethernet cables, wireless networks etc
2. Internet layer: controls the movement of packets around the network
3. Transport layer: provides a reliable connection between the 2 devices essentially ensuring the receiving device has gotten hold of the all the packets 
4. Application layer: this represents the applications that the user interacts with e.g. email

- If you have heard that using public WiFi is not the safest option, that is because this form of communication is not private, thereby making the possible private data being sent vulnerable to access by unauthorized parties.

## Firewalls

- Historically firewalls referred to literal walls intended to contain fire from spreading to other buildings, this form of usage is close to the technological use of firewalls i.e., control of network traffic by selectively allowing or blocking data packets to pass through.
-  Firewalls enhance network security by intercepting malicious data packets and can be used with added DNS-based filtering to perform content filtering to deny access to unwanted URLs.
- There are different types of firewalls namely: proxy firewalls, stateful firewalls, next-gen firewalls among others.
- They can be deployed in different methods i.e., hardware-based, software-based or cloud firewalls.

## HTTPS/SSL

- When a user accesses a site on a browser, there are certain sites that have a padlock icon appearing next to the URL; this means that the site being accessed is secure.
- HTTP is a protocol widely used for communication between browsers and web servers; HTTPS is the version of HTTP that has been secured by the Secure Sockets Layer (SSL) which encrypts the data being sent between a website and a browser in the user’s computer.
- When a HTTPS connection to a webpage is requested, an exchange occurs between the website which sends its SSL certificate to the browser containing a public key to begin the secure session; this initiates an SSL handshake that encrypts communication between the browser and the website.

## Load Balancer

- In the quest for information retrieval across the internet, the user computer will encounter a load balancer which acts as a distributor of traffic to servers that contain the required information.
- Load balancers rely on algorithms that dictate the distribution of traffic such as round-robin method whereby an authoritative nameserver returns the IP addresses of different servers in the server farm one by one.
- Other algorithms such as weighted round-robin involve assignment of different weights to each server based on their priority or capacity.
- Load balancers are essentially the bridge between the user computer and the servers containing the requested data.

## Web Server

- This server component is responsible for managing HTTP requests and responses, for a website, it accesses the source code and returns static content i.e. the HTML webpage of the website. Nginx is an example of a widely used web server.

## Application Server

- Provides the web server with the dynamic content of the website i.e., the business logic such as adding or updating information.

Here is a schema illustrating the flow of the request created when you type in a URL in your browser and press Enter.

![Flow of the request](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kte9n703vjkbvmh86ing.png)

## References
https://www.hostinger.com/tutorials/what-is-dns
https://www.avast.com/c-what-is-tcp-ip#
https://nordlayer.com/learn/firewall/what-is-firewall/
https://www.instantssl.com/http-vs-https
https://aws.amazon.com/what-is/load-balancing/
https://en.wikipedia.org/wiki/Web_server