Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédente | |||
| elearning:workbooks:lpic:22:450:l102 [2022/11/22 10:45] – admin | elearning:workbooks:lpic:22:450:l102 [2022/11/22 13:43] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 58: | Ligne 58: | ||
| * LAB #13 - Améliorer l' | * LAB #13 - Améliorer l' | ||
| * **Le Serveur Mandataire Squid** | * **Le Serveur Mandataire Squid** | ||
| - | * Installation | + | * LAB #14 - Installation |
| - | * Configuration | + | * LAB #15 - L' |
| - | * L' | + | * LAB #16 - Dansguardian |
| - | * T.P. #1 | + | * **Le Serveur HTTP Nginx** |
| - | * Créer une whitelist | + | * LAB #17 - Configuration d'un Proxy Inverse |
| - | * Dansguardian | + | * LAB #18 - Configuration d'un Serveur PHP |
| * **Ne Pas Oublier** | * **Ne Pas Oublier** | ||
| * Server Name Indication | * Server Name Indication | ||
| Ligne 6285: | Ligne 6285: | ||
| - | =====Installation===== | + | ====LAB #14 - Installation |
| Utilisez yum : | Utilisez yum : | ||
| Ligne 6354: | Ligne 6354: | ||
| squid 0: | squid 0: | ||
| </ | </ | ||
| - | |||
| - | ====Options de la commande squid==== | ||
| Les options de cette commande sont : | Les options de cette commande sont : | ||
| Ligne 6385: | Ligne 6383: | ||
| </ | </ | ||
| - | =====Configuration===== | + | Créez |
| - | + | ||
| - | Créez un fichier squid.conf sans commentaires : | + | |
| < | < | ||
| Ligne 6547: | Ligne 6543: | ||
| </ | </ | ||
| - | + | ====LAB #15 - L' | |
| - | =====L' | + | |
| **squidGuard** est une **extension** pour le serveur proxy **Squid**. **squidGuard** est un **redirecteur** qui permet de filtrer l' | **squidGuard** est une **extension** pour le serveur proxy **Squid**. **squidGuard** est un **redirecteur** qui permet de filtrer l' | ||
| Ligne 7188: | Ligne 7183: | ||
| [root@centos6 squidguard]# | [root@centos6 squidguard]# | ||
| - | |||
| - | ====Options de la commande squidguard==== | ||
| Les options de cette commande sont : | Les options de cette commande sont : | ||
| Ligne 7207: | Ligne 7200: | ||
| </ | </ | ||
| - | =====T.P. #1===== | + | ====Créer une whitelist==== |
| - | + | ||
| - | <WRAP center round important> | + | |
| - | Configurez votre navigateur afin d' | + | |
| - | </ | + | |
| - | + | ||
| - | =====Créer une whitelist===== | + | |
| Trouver le site de google.de dans les fichiers de squidGuard est une tâche fastidieuse, | Trouver le site de google.de dans les fichiers de squidGuard est une tâche fastidieuse, | ||
| Ligne 7426: | Ligne 7413: | ||
| </ | </ | ||
| - | =====Dansguardian===== | + | ====LAB #16 - Dansguardian==== |
| Squid ne peut pas contrôler le //contenu// des pages web. Pour faire ceci, il faut utiliser un logiciel de filtrage du contenu tel **Dansguardian** : | Squid ne peut pas contrôler le //contenu// des pages web. Pour faire ceci, il faut utiliser un logiciel de filtrage du contenu tel **Dansguardian** : | ||
| Ligne 7489: | Ligne 7476: | ||
| Configurez votre navigateur afin d' | Configurez votre navigateur afin d' | ||
| + | |||
| + | =====Le Serveur HTTP Nginx===== | ||
| + | |||
| + | ====Présentation et Configuration de Nginx sous Debian 11==== | ||
| + | |||
| + | Commencez par vous connectez à votre VM Debian 11 au 10.0.2.46. | ||
| + | |||
| + | ====Présentation==== | ||
| + | |||
| + | Nginx est un logiciel libre de serveur Web ainsi qu'un proxy inverse écrit par Igor Sysoev, dont le développement a débuté en 2002 pour les besoins d'un site russe à très fort trafic (Rambler). La documentation est disponible dans plusieurs langues. | ||
| + | |||
| + | NGINX Inc a été racheté par F5 Networks le 11 mars 2019, pour 670 millions de dollars. | ||
| + | |||
| + | Ses sources sont disponibles sous une licence de type BSD. | ||
| + | |||
| + | ====LAB #17 - Configuration d'un Proxy Inverse==== | ||
| + | |||
| + | Installez nginx et gunicorn : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : Gunicorn est un Python WSGI server. | ||
| + | </ | ||
| + | |||
| + | Créez le fichier **/ | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | root@debian11: | ||
| + | server { | ||
| + | listen 80; | ||
| + | listen [::]:80; | ||
| + | |||
| + | server_name reverse-proxy.loc www.reverse-proxy.loc; | ||
| + | | ||
| + | location / { | ||
| + | proxy_pass http:// | ||
| + | include proxy_params; | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : La directive **proxy-pass** indique l'URL de Gunicorn. | ||
| + | </ | ||
| + | |||
| + | Consultez le contenu du fichier **/ | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | proxy_set_header Host $http_host; | ||
| + | proxy_set_header X-Real-IP $remote_addr; | ||
| + | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| + | proxy_set_header X-Forwarded-Proto $scheme; | ||
| + | </ | ||
| + | |||
| + | Vérifiez la syntaxe de votre fichier **/ | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | nginx: the configuration file / | ||
| + | nginx: configuration file / | ||
| + | </ | ||
| + | |||
| + | Créez le lien symbolique pour **reverse-proxy.loc** dans le répertoire **/ | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | </ | ||
| + | |||
| + | Editez le fichier **/ | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | root@debian11: | ||
| + | 127.0.0.1 | ||
| + | 10.0.2.46 | ||
| + | 10.0.2.46 | ||
| + | |||
| + | # The following lines are desirable for IPv6 capable hosts | ||
| + | ::1 | ||
| + | ff02::1 ip6-allnodes | ||
| + | ff02::2 ip6-allrouters | ||
| + | </ | ||
| + | |||
| + | Redémarrez le serveur nginx : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | root@debian11: | ||
| + | ● nginx.service - A high performance web server and a reverse proxy server | ||
| + | | ||
| + | | ||
| + | Docs: man: | ||
| + | Process: 1927 ExecStartPre=/ | ||
| + | Process: 1928 ExecStart=/ | ||
| + | Main PID: 1929 (nginx) | ||
| + | Tasks: 9 (limit: 19150) | ||
| + | | ||
| + | CPU: 30ms | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | Nov 22 13:03:56 debian11 systemd[1]: nginx.service: | ||
| + | Nov 22 13:03:56 debian11 systemd[1]: Stopped A high performance web server and a reve> | ||
| + | lines 1-23 | ||
| + | </ | ||
| + | |||
| + | Créez le fichier une fonction Python qui retournera **Hello World!** en tant que réponse HTTP : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | root@debian11: | ||
| + | def app(environ, | ||
| + | start_response(" | ||
| + | return iter([b" | ||
| + | </ | ||
| + | |||
| + | Lancez Gunicorn : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | [1] 1944 | ||
| + | root@debian11: | ||
| + | [2022-11-22 13:05:38 +0100] [1944] [INFO] Listening at: http:// | ||
| + | [2022-11-22 13:05:38 +0100] [1944] [INFO] Using worker: sync | ||
| + | [2022-11-22 13:05:38 +0100] [1945] [INFO] Booting worker with pid: 1945 | ||
| + | [2022-11-22 13:05:39 +0100] [1946] [INFO] Booting worker with pid: 1946 | ||
| + | [Enter] | ||
| + | root@debian11: | ||
| + | </ | ||
| + | |||
| + | Consultez le site **reverse-proxy.loc** : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | Hello, World!root@debian11: | ||
| + | root@debian11: | ||
| + | </ | ||
| + | |||
| + | ====LAB #18 - Configuration d'un Serveur PHP==== | ||
| + | |||
| + | Commencez par installe **php** et **php-fpm** : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | </ | ||
| + | |||
| + | Vérifiez la version de PHP installée : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | PHP 7.4.33 (cli) (built: Nov 8 2022 11:40:37) ( NTS ) | ||
| + | Copyright (c) The PHP Group | ||
| + | Zend Engine v3.4.0, Copyright (c) Zend Technologies | ||
| + | with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies | ||
| + | </ | ||
| + | |||
| + | Modifiez maintenant le fichier **/ | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | root@debian11: | ||
| + | server { | ||
| + | listen 80; | ||
| + | server_name reverse-proxy.loc; | ||
| + | root / | ||
| + | |||
| + | index index.html index.htm index.php; | ||
| + | |||
| + | location / { | ||
| + | try_files $uri $uri/ =404; | ||
| + | } | ||
| + | |||
| + | location ~ \.php$ { | ||
| + | include snippets/ | ||
| + | fastcgi_pass unix:/ | ||
| + | } | ||
| + | |||
| + | location ~ /\.ht { | ||
| + | deny all; | ||
| + | } | ||
| + | |||
| + | } | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : Notez que la directive **root** définit le chemin vers les pages du contenu du site et que la directive **listen** spécifie le port d' | ||
| + | </ | ||
| + | |||
| + | Créez le fichier **/ | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | root@debian11: | ||
| + | <?php | ||
| + | phpinfo(); | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | Redémarrez le serveur nginx pour une pris en compte directe des modifications : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | root@debian11: | ||
| + | ● nginx.service - A high performance web server and a reverse proxy server | ||
| + | | ||
| + | | ||
| + | Docs: man: | ||
| + | Process: 9799 ExecStartPre=/ | ||
| + | Process: 9800 ExecStart=/ | ||
| + | Main PID: 9801 (nginx) | ||
| + | Tasks: 9 (limit: 19150) | ||
| + | | ||
| + | CPU: 33ms | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | Nov 22 13:43:30 debian11 systemd[1]: Starting A high performance web server and a rev> | ||
| + | Nov 22 13:43:30 debian11 systemd[1]: Started A high performance web server and a reve> | ||
| + | root@debian11: | ||
| + | </ | ||
| + | |||
| + | Consultez ensuite la page **info.php** : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | % Total % Received % Xferd Average Speed | ||
| + | | ||
| + | 100 65721 0 65721 0 | ||
| + | k 0l.dtd"> | ||
| + | | ||
| + | <html xmlns=" | ||
| + | <style type=" | ||
| + | body {background-color: | ||
| + | pre {margin: 0; font-family: | ||
| + | a:link {color: #009; text-decoration: | ||
| + | a:hover {text-decoration: | ||
| + | table {border-collapse: | ||
| + | c;} | ||
| + | .center {text-align: | ||
| + | .center table {margin: 1em auto; text-align: left;} | ||
| + | .center th {text-align: | ||
| + | td, th {border: 1px solid #666; font-size: 75%; vertical-align: | ||
| + | 5px;} | ||
| + | th {position: sticky; top: 0; background: inherit;} | ||
| + | h1 {font-size: 150%;} | ||
| + | h2 {font-size: 125%;} | ||
| + | .p {text-align: | ||
| + | .e {background-color: | ||
| + | .h {background-color: | ||
| + | .v {background-color: | ||
| + | } | ||
| + | --More-- | ||
| + | [q] | ||
| + | </ | ||
| + | |||
| =====Ne Pas Oublier===== | =====Ne Pas Oublier===== | ||