What is a Web Server?

What is a Web Server?

To understand Web Servers, you should first know how the Internet and the Web work.

How does the Internet work?

When two computers want to communicate then there must be a connection between them, this connection is the Internet which can be physical (wired ethernet cable) or wireless (WiFi).

Let's take a scenario, you want to send a message from Computer A to Computer B, for this, you can plug a cable into both the computer's plugins and send the message to and fro.

What if you want to connect 10 computers and transfer messages between them? You would need more cables and more plugins too!! To solve this problem, a router is introduced. The router helps to transfer the data or message from a specified computer to the destination computer. Your network of 10 computers will now only requires 10 cables: a single plug for each computer and a router with 10 plugs.

What if you want to connect hundreds, thousands, and millions of computers? Ofcourse, a single router can't handle multiple connections, you can achieve this by connecting routers, each router is connected to several computers in its network, and now all the routers are connected forming a network of networks.

What if you want to connect to a computer on another network? Your neighbour's network or your friend's network which they created? It's not possible to set up cables between your house and the rest of the world, so how can you handle this? Well, there are already cables that are linked to your house example telephone network, or an electricity network.

The telephone system already connects you with anyone in the world, to connect your network to the telephone infrastructure, a modem is used. This modem turns the information from your network into information manageable by the telephone infrastructure and vice versa. To send the messages from your network to the network you want to reach, you will connect your network to an Internet Service Provider (ISP). An ISP is a company that manages routers that are linked together and can also access other ISPs' routers. The message from your network is carried through the network of ISP networks to the destination network.

If you want to send a message to a computer, you have to specify which one. All the computers linked to a network have a unique address that identifies them, called an "IP address". An IP address is a series of four numbers separated by dots 192.150.30.78. It's difficult to remember IP addresses, so to make our lives easier domain name is introduced. For example, google.com is the domain name used on top of the IP address 142.250.190.78.

Web browser, Webpage, Website, Search Engine, HTTP??

  • A webpage is a document displayed in a web browser.

  • A website is a collection of web pages which are grouped.

  • A search engine is a web service that helps you find other web pages, such as Google, Bing, and Yahoo.

  • A web browser is an application program that retrieves and displays pages from the Web (Chrome, Safari), When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's screen.

  • HTTP(Hypertext Transfer Protocol) specifies how to transfer hypertext (linked web documents) between two computers, a protocol is a set of rules for communication between two computers.

How does the web work?

Computers that are connected to the internet are called clients and servers.

  • Clients are internet-connected devices (for example, your computer connected to your Wi-Fi, or your phone connected to your mobile network) and web browsers.

  • Servers are computers that store webpages, websites, or apps. When a client device wants to access a webpage, then a copy of the webpage is downloaded from the server onto the client machine and displayed in the user's web browser.

    What happens exactly when you type a web address into your browser??

    1. The browser goes to the DNS server and finds the IP address of the server that the website lives on.

    2. The browser sends an HTTP request message to the server, asking it to send a copy of the website to the client. This message, and all other data sent between the client and the server, is sent across your internet connection using TCP/IP.

    3. If the server approves the client's request, the server sends the client a "200 OK" message and then starts sending the website's files to the browser as a series of small chunks called data packets.

    4. The browser assembles the small chunks into a complete web page and displays it to you.

Now let's understand more about web servers:

Web server acts as both software and hardware. Web server stores the webpages, HTML codes, CSS, Javascript files, and images as well as HTTP server which is software that understands URL's (web addresses) and HTTP(the protocol browser uses to view webpages).

Whenever you need some data, the browser displays it to you, for that browser needs the file that is hosted on a web server, the browser requests the file via HTTP. When the request from the browser reaches the correct web server (hardware), then the HTTP server(software) accepts the request, finds the requested file and sends it back to the browser through HTTP. If the server does not find the requested file then it returns a 404 error page.

Examples: Apache, NGINX.