Skip to content

Commit

Permalink
Reorganize web services book (#2235)
Browse files Browse the repository at this point in the history
* correct some content that was incorrect
* mostly this PR is focused on reorganization, more editing will be required
  • Loading branch information
sspencerwire authored Aug 5, 2024
1 parent 97dad7e commit e24dc65
Show file tree
Hide file tree
Showing 9 changed files with 692 additions and 644 deletions.
7 changes: 6 additions & 1 deletion docs/books/web_services/01-files-servers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ tags:
- ftp
- sftp
---

!!! info

The content for this page has yet to be written.

<!---
# Part 1. Files Servers
Expand Down Expand Up @@ -104,4 +109,4 @@ In this chapter, you will learn about XXXXXXX.
* [ ] Answer 3
* [ ] Answer 4
-->
-->
92 changes: 92 additions & 0 deletions docs/books/web_services/02-web-servers-intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
author: Antoine Le Morvan
contributors: Steven Spencer, Ganna Zhyrnova
title: Part 2. Web Servers Introduction
---

## Introduction

### HTTP protocol

**HTTP** (**H**yper**T**ext **T**ransfer **P**rotocol) has been the most widely used protocol on the Internet since 1990.

This protocol enables the transfer of files (mainly in HTML format, but also in CSS, JS, AVI...) localized by a character string called **URL** between a browser (the client) and a Web server (called `httpd` on UNIX machines).

HTTP is a "request-response" protocol operating on top of **TCP** (**T**ransmission **C**ontrol **P**rotocol).

1. The client opens a TCP connection to the server and sends a request.
2. The server analyzes the request and responds according to its configuration.

The HTTP protocol is "**STATELESS**": it does not retain any information about the client's state from one request to the next. Dynamic languages such as php, python, or java store client session information in memory (as on an e-commerce site, for example).

The current HTTP protocols are version 1.1, used widely, and versions 2 and 3 which are gaining adoption.

An HTTP response is a set of lines sent to the browser by the server. It includes:

* A **status line**: this specifies the protocol version used and the processing status of the request, using a code and explanatory text. The line comprises three elements separated with a space:
* The protocol version used
* The status code
* The meaning of the code

* **Response header fields**: these are a set of optional lines providing additional information about the response and/or the server. Each of these lines consists of a name qualifying the header type, followed by a colon (:) and the header value.

* **The response body**: this contains the requested document.

Here is an example of an HTTP response:

```bash
$ curl --head --location https://docs.rockylinux.org
HTTP/2 200
accept-ranges: bytes
access-control-allow-origin: *
age: 109725
cache-control: public, max-age=0, must-revalidate
content-disposition: inline
content-type: text/html; charset=utf-8
date: Fri, 21 Jun 2024 12:05:24 GMT
etag: "cba6b533f892339d3818dc59c3a5a69a"
server: Vercel
strict-transport-security: max-age=63072000
x-vercel-cache: HIT
x-vercel-id: cdg1::pdqbh-1718971524213-4892bf82d7b2
content-length: 154696
```

!!! NOTE

Learning the `curl` command usage will be very helpfull for you to troubleshoot your servers in the future.

The role of the web server is to translate a URL into a local resource. Consulting the <https://docs.rockylinux.org/> page is like sending an HTTP request to this machine. The DNS service plays an essential role.

### URLs

A **URL** (**U**niform **R**esource **L**ocator) is an ASCII character string used to designate resources on the Internet. It is informally referred to as a web address.

A URL has three parts:

```text
<protocol>://<host>:<port>/<path>
```

* **Protocol name**: this is the language used to communicate over the network, for example HTTP, HTTPS, FTP, and so on. The most widely used protocols are HTTP (HyperText TransferProtocol) and its secure version HTTPS, the protocol used to exchange Web pages in HTML format.

* **Login** and **password**: allows you to specify access parameters to a secure server. This option is not recommended, as the password is visible in the URL (for security purposes).

* **Host**: This is the name of the computer hosting the requested resource. Note that it is possible to use the server's IP address, which makes the URL less readable.

* **Port number**: this is a number associated with a service, enabling the server to know the requested resource type. The default port associated with the HTTP protocol is port number 80 and 443 with HTTPS. So, when the protocol in use is HTTP or HTTPS
, the port number is optional.

* Resource path: This part lets the server know the location of the resource. Generally, the location (directory) and name of the requested file. If nothing in the address specifies a location, it indicates the first page of the host. Otherwise it indicates the path to the page to display.

### Ports

An HTTP request will arrive on port 80 (default port for http) of the server running on the host. However, the administrator is free to choose the server's listening port.

The http protocol is available in a secure version: the https protocol (port 443). Implement this encrypted protocol with the `mod_ssl` module.

Using other ports is also possible, such as port `8080` (Java EE application servers).

## Apache and Nginx

The two most common web servers for Linux are Apache and Nginx. These will be discussed in the following chapters.
Original file line number Diff line number Diff line change
@@ -1,91 +1,9 @@
---
author: Antoine Le Morvan
contributors: Steven Spencer, Ganna Zhyrnova
title: Part 2. Web Servers
title: Part 2.1 Web Servers Apache
---

## Introduction

### HTTP Protocol

**HTTP** (**H**yper**T**ext **T**ransfer **P**rotocol) has been the most widely used protocol on the Internet since 1990.

This protocol enables the transfer of files (mainly in HTML format, but also in CSS, JS, AVI...) localized by a character string called **URL** between a browser (the client) and a Web server (called `httpd` on UNIX machines).

HTTP is a "request-response" protocol operating on top of **TCP** (**T**ransmission **C**ontrol **P**rotocol).

1. The client opens a TCP connection to the server and sends a request.
2. The server analyzes the request and responds according to its configuration.

The HTTP protocol is "**STATELESS**": it does not retain any information about the client's state from one request to the next. Dynamic languages such as php, python, or java store client session information in memory (as on an e-commerce site, for example).

The HTTP protocol is version 1.1. Version 2 is still under development.

An HTTP response is a set of lines sent to the browser by the server. It includes:

* A **status line**: this specifies the protocol version used and the processing status of the request, using a code and explanatory text. The line comprises three elements separated with a space:
* The protocol version used
* The status code
* The meaning of the code

* **Response header fields**: these are a set of optional lines providing additional information about the response and/or the server. Each of these lines consists of a name qualifying the header type, followed by a colon (:) and the header value.

* **The response body**: this contains the requested document.

Here is an example of an HTTP response:

```bash
$ curl --head --location https://docs.rockylinux.org
HTTP/2 200
accept-ranges: bytes
access-control-allow-origin: *
age: 109725
cache-control: public, max-age=0, must-revalidate
content-disposition: inline
content-type: text/html; charset=utf-8
date: Fri, 21 Jun 2024 12:05:24 GMT
etag: "cba6b533f892339d3818dc59c3a5a69a"
server: Vercel
strict-transport-security: max-age=63072000
x-vercel-cache: HIT
x-vercel-id: cdg1::pdqbh-1718971524213-4892bf82d7b2
content-length: 154696
```

!!! NOTE

Learning the `curl` command usages will be very helpfull for you to troubleshoot your servers in the future.

The role of the web server is to translate a URL into a local resource. Consulting the <https://docs.rockylinux.org/> page is like sending an HTTP request to this machine. The DNS service therefore plays an essential role.

### URLs

A **URL** (**U**niform **R**esource **L**ocator) is an ASCII character string used to designate resources on the Internet. It is informally referred to as a web address.

A URL has three parts:

```text
<protocol>://<host>:<port>/<path>
```

* **Protocol name**: this is the language used to communicate over the network, for example HTTP, HTTPS, FTP, and so on. The most widely used protocols are HTTP (HyperText TransferProtocol) and its secure version HTTPS, the protocol used to exchange Web pages in HTML format.

* **Login** and **password**: allows you to specify access parameters to a secure server. This option is not recommended, as the password is visible in the URL (for security purposes).

* **Host**: This is the name of the computer hosting the requested resource. Note that it is possible to use the server's IP address, which makes the URL less readable.

* **Port number**: this is a number associated with a service, enabling the server to know the requested resource type. The default port associated with the HTTP protocol is port number 80 and 443 with HTTPS. So, when the protocol in use is HTTP or HTTPS, the port number is optional.

* Resource path: This part lets the server know the location of the resource. Generally, the location (directory) and name of the requested file. If nothing in the address specifies a location, it indicates the first page of the host. Otherwise it indicates the path to the page to display.

### Ports

An HTTP request will arrive on port 80 (default port for http) of the server running on the host. However, the administrator is free to choose the server's listening port.

The http protocol is available in a secure version: the https protocol (port 443). Implement this encrypted protocol with the `mod_ssl` module.

Using other ports is also possible, such as port `8080` (Java EE application servers).

## Apache

In this chapter, you will learn about Apache, the web server.
Expand All @@ -98,8 +16,8 @@ In this chapter, you will learn about Apache, the web server.

:checkered_flag: **apache**, **http**, **httpd**

**Knowledge**: :star: :star:
**Complexity**: :star: :star:
**Knowledge**: :star: :star:
**Complexity**: :star: :star:

**Reading time**: 30 minutes

Expand Down
10 changes: 10 additions & 0 deletions docs/books/web_services/022-web-servers-nginx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
author:
contributors:
title: Part 2.2 Web Servers Nginx
---

!!! info

This content is not written yet.

12 changes: 6 additions & 6 deletions docs/books/web_services/03-application-servers.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tags:
- php-fpm
- application server
- dynamic language
---
---

## PHP and PHP-FPM

Expand All @@ -22,14 +22,14 @@ In this chapter, you will learn about PHP and PHP-FPM.

**Objectives**: In this chapter, you will learn how to:

:heavy_check_mark: install a PHP application server
:heavy_check_mark: configure PHP-FPM pool
:heavy_check_mark: optimize a PHP-FPM application server
:heavy_check_mark: install a PHP application server
:heavy_check_mark: configure PHP-FPM pool
:heavy_check_mark: optimize a PHP-FPM application server

:checkered_flag: **PHP**, **PHP-FPM**, **Application server**

**Knowledge**: :star: :star: :star:
**Complexity**: :star: :star: :star:
**Knowledge**: :star: :star: :star:
**Complexity**: :star: :star: :star:

**Reading time**: 30 minutes

Expand Down
9 changes: 9 additions & 0 deletions docs/books/web_services/04-database-servers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
author:
contributors:
title: Part 4. Database Servers
---

!!! info

An introduction to relational database servers needs to be written.
Loading

0 comments on commit e24dc65

Please sign in to comment.