|
|
@@ -0,0 +1,693 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
|
|
+<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
|
|
+<head>
|
|
|
+ <meta charset="utf-8">
|
|
|
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <link rel="shortcut icon" href="../../../img/favicon.ico">
|
|
|
+ <title>Exemple d'utilisation avec un serveur Web - Les Tutoriels du Yojik</title>
|
|
|
+ <link rel="stylesheet" href="../../../css/theme.css" />
|
|
|
+ <link rel="stylesheet" href="../../../css/theme_extra.css" />
|
|
|
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" />
|
|
|
+
|
|
|
+ <script>
|
|
|
+ // Current page data
|
|
|
+ var mkdocs_page_name = "Exemple d'utilisation avec un serveur Web";
|
|
|
+ var mkdocs_page_input_path = "Tutoriels/tutoraspi/Exemple-d-utilisation-serveur-Web.md";
|
|
|
+ var mkdocs_page_url = null;
|
|
|
+ </script>
|
|
|
+
|
|
|
+ <script src="../../../js/jquery-2.1.1.min.js" defer></script>
|
|
|
+ <script src="../../../js/modernizr-2.8.3.min.js" defer></script>
|
|
|
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
|
|
|
+ <script>hljs.initHighlightingOnLoad();</script>
|
|
|
+
|
|
|
+</head>
|
|
|
+
|
|
|
+<body class="wy-body-for-nav" role="document">
|
|
|
+
|
|
|
+ <div class="wy-grid-for-nav">
|
|
|
+
|
|
|
+
|
|
|
+ <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
|
|
|
+ <div class="wy-side-scroll">
|
|
|
+ <div class="wy-side-nav-search">
|
|
|
+ <a href="../../.." class="icon icon-home"> Les Tutoriels du Yojik</a>
|
|
|
+ <div role="search">
|
|
|
+ <form id ="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
|
|
|
+ <input type="text" name="q" placeholder="Search docs" title="Type search term here" />
|
|
|
+ </form>
|
|
|
+</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
|
+ <p class="caption"><span class="caption-text">Home</span></p>
|
|
|
+ <ul>
|
|
|
+ <li class="toctree-l1"><a class="reference internal" href="../../..">Page d'accueil</a>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ <p class="caption"><span class="caption-text">Tutoriels</span></p>
|
|
|
+ <ul class="current">
|
|
|
+ <li class="toctree-l1"><a class="reference internal" href="../../tutos/">Introduction</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l1"><a class="reference internal" href="#">Installation d'un serveur sécurisé, version Debian/Stretch (obsolète)</a>
|
|
|
+ <ul>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../../tutostretch/tutostretch/">Présentation</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="#">Installation</a>
|
|
|
+ <ul>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Installation-de-base/">Installation du système de base</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/ovh/">Démarrage sur serveur OVH</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Premi%C3%A8re-Etape-S%C3%A9curisation/">Première étapes de sécurisation du serveur</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Configuration-R%C3%A9seau/">Configuration du réseau</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Installation-Serveur-Temps/">Installation d'un serveur de temps</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Installation-Parre-Feu/">Installation d'un pare-feu</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Installation-Fail2ban/">Contrer les attaques de brute-force avec fail2ban</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Installation-Serveur-Courrier-Basique/">Installation d'un serveur de courrier basique</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Installation-Serveur-DNS/">Installation du serveur DNS</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Installation-Serveur-Web/">Installation d'un serveur web</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Installation-Dovecot-Authentification/">Installation de dovecot et de l'authentification</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="" href="../../tutostretch/Installation-Certificats-Letsencrypt.md)">Installation des certificats letsencrypt</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="" href="../../tutostretch/courrier-SPF-DKIM-OPENDMARC.md">Ajout des enregistrements **spf**, **DKIM**, **DMARC** au fichier de zone DNS</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Courrier-Comptes-Virtuels/">Ajout des comptes émail virtuels</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Surveillance-Serveur/">Installation de programmes de surveillance du serveur</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="../../tutostretch/Installation-Webmail/">Installation d'un webmail (rainloop)</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="" href="../../tutostretch/Sécurisation-Serveur-Web">Sécurisation d'un serveur WEB</a>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l1"><a class="reference internal" href="#">Installation d'un serveur sécurisé, version Debian/Buster (en cours d'écriture)</a>
|
|
|
+ <ul>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/1-tutobuster/">Présentation</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/2-Installation-de-base/">Installation de base</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/3-ovh/">Démarrage sur serveur OVH</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/4-Plan/">Plan d'ensemble</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/5-Premi%C3%A8re-Etape-S%C3%A9curisation/">Premières étapes de sécurisation du serveur</a>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l1 current"><a class="reference internal current" href="#">Installation d'un serveur sécurisé, version Debian/Buster sur RaspberryPI</a>
|
|
|
+ <ul class="current">
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../R%C3%A9sum%C3%A9/">Résumé</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../tutoraspi/">Présentation</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../Installation-de-base/">Installation de base</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../Premier-d%C3%A9marrage/">Premier démarrage</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../Etat-des-lieux/">État des lieux</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../S%C3%A9curisation-SSH/">Sécurisation SSH</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../R%C3%A9seau/">Réseau (des IPs fixes)</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../Knot/">Installation de Knot-resolver</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../Firewall/">Installation d'un pare-feux</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../Fail2ban/">Contrer les attaques de force brute</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../Logwatch/">Surveillance du serveur</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../Installation-courrier-basique/">Installation d'un serveur de courriers basique</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2 current"><a class="reference internal current" href="./">Exemple d'utilisation avec un serveur Web</a>
|
|
|
+ <ul class="current">
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="#installation-du-programme">Installation du programme</a>
|
|
|
+ <ul>
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#installation">Installation</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#ouverture-des-ports">Ouverture des ports</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#test">Test</a>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="#creation-de-la-page-daccueil">Création de la page d'accueil</a>
|
|
|
+ <ul>
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#la-page-daccueil">La page d'accueil</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#creation-du-virtualhost-correspondant">Création du virtualhost correspondant</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#test-de-notre-page-daccueil">Test de notre page d'accueil</a>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l3"><a class="reference internal" href="#securisation-de-notre-serveur">Sécurisation de notre serveur</a>
|
|
|
+ <ul>
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#etat-des-lieux">État des lieux</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#test-de-notre-nouvelle-configuration">Test de notre nouvelle configuration</a>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#petites-ameliorations-supplementaires">Petites améliorations supplémentaires</a>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ <li class="toctree-l2"><a class="reference internal" href="../Annexe/">Annexe</a>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </nav>
|
|
|
+
|
|
|
+ <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
+
|
|
|
+
|
|
|
+ <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
|
|
+ <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
|
+ <a href="../../..">Les Tutoriels du Yojik</a>
|
|
|
+ </nav>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="wy-nav-content">
|
|
|
+ <div class="rst-content">
|
|
|
+ <div role="navigation" aria-label="breadcrumbs navigation">
|
|
|
+ <ul class="wy-breadcrumbs">
|
|
|
+ <li><a href="../../..">Docs</a> »</li>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <li>Installation d'un serveur sécurisé, version Debian/Buster sur RaspberryPI »</li>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <li>Tutoriels »</li>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <li>Exemple d'utilisation avec un serveur Web</li>
|
|
|
+ <li class="wy-breadcrumbs-aside">
|
|
|
+
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+
|
|
|
+ <hr/>
|
|
|
+</div>
|
|
|
+ <div role="main">
|
|
|
+ <div class="section">
|
|
|
+
|
|
|
+ <h1 id="exemple-dutilisation-de-notre-tout-nouveau-raspi">Exemple d'utilisation de notre tout nouveau Raspi</h1>
|
|
|
+<p>Nous allons installer un serveur Web, <strong>apache</strong>.</p>
|
|
|
+<p>Ce n'est qu'un exemple : choisissez le logiciel que vous voulez, mais gardez à l'esprit la sécurisation.</p>
|
|
|
+<h2 id="installation-du-programme">Installation du programme</h2>
|
|
|
+<h3 id="installation">Installation</h3>
|
|
|
+<pre><code>pi@piras:~ $ sudo apt install apache2
|
|
|
+Lecture des listes de paquets... Fait
|
|
|
+Construction de l'arbre des dépendances
|
|
|
+Lecture des informations d'état... Fait
|
|
|
+Les paquets supplémentaires suivants seront installés :
|
|
|
+apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 liblua5.2-0
|
|
|
+Paquets suggérés :
|
|
|
+apache2-doc apache2-suexec-pristine | apache2-suexec-custom
|
|
|
+Les NOUVEAUX paquets suivants seront installés :
|
|
|
+apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1
|
|
|
+liblua5.2-0
|
|
|
+0 mis à jour, 10 nouvellement installés, 0 à enlever et 0 non mis à jour.
|
|
|
+Il est nécessaire de prendre 2 309 ko dans les archives.
|
|
|
+Après cette opération, 7 253 ko d'espace disque supplémentaires seront utilisés.
|
|
|
+Souhaitez-vous continuer ? [O/n] o
|
|
|
+...
|
|
|
+Enabling site 000-default.
|
|
|
+Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
|
|
|
+Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.
|
|
|
+service.
|
|
|
+Traitement des actions différées (« triggers ») pour systemd (241-7~deb10u6+rpi1) ...
|
|
|
+Traitement des actions différées (« triggers ») pour man-db (2.8.5-2) ...
|
|
|
+Traitement des actions différées (« triggers ») pour libc-bin (2.28-10+rpi1) ...
|
|
|
+pi@piras:~ $
|
|
|
+</code></pre>
|
|
|
+<h3 id="ouverture-des-ports">Ouverture des ports</h3>
|
|
|
+<p>Il nous faut ajouter les services <strong>http</strong> et <strong>https</strong>.</p>
|
|
|
+<ol>
|
|
|
+<li>
|
|
|
+<p>Règles en cours</p>
|
|
|
+<pre><code>pi@piras:~ $ sudo firewall-cmd --state
|
|
|
+running
|
|
|
+pi@piras:~ $ sudo firewall-cmd --get-default-zone
|
|
|
+public
|
|
|
+pi@piras:~ $ sudo firewall-cmd --get-active-zones
|
|
|
+public
|
|
|
+interfaces: eth0
|
|
|
+pi@piras:~ $ sudo firewall-cmd --list-all
|
|
|
+public (active)
|
|
|
+target: default
|
|
|
+icmp-block-inversion: no
|
|
|
+interfaces: eth0
|
|
|
+sources:
|
|
|
+services: dhcpv6-client smtp ssh
|
|
|
+ports:
|
|
|
+protocols:
|
|
|
+masquerade: no
|
|
|
+forward-ports:
|
|
|
+source-ports:
|
|
|
+icmp-blocks:
|
|
|
+rich rules:
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>Ajout des services</p>
|
|
|
+<pre><code>pi@piras:~ $ sudo firewall-cmd --permanent --zone=public --add-service={http,https}
|
|
|
+success
|
|
|
+pi@piras:~ $
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>Test de nos services actifs</p>
|
|
|
+<p>J'ai relancé le raspi car j'avais des erreurs de <strong>zones</strong>.</p>
|
|
|
+<p>Après redémarrage, tout est bon :</p>
|
|
|
+<pre><code>pi@piras:~ $ sudo firewall-cmd --list-all
|
|
|
+public (active)
|
|
|
+target: default
|
|
|
+icmp-block-inversion: no
|
|
|
+interfaces: eth0
|
|
|
+sources:
|
|
|
+services: dhcpv6-client http https smtp ssh
|
|
|
+ports:
|
|
|
+protocols:
|
|
|
+masquerade: no
|
|
|
+forward-ports:
|
|
|
+source-ports:
|
|
|
+icmp-blocks:
|
|
|
+rich rules:
|
|
|
+
|
|
|
+pi@piras:~ $
|
|
|
+</code></pre>
|
|
|
+<p>Nos services <strong>http</strong> et <strong>https</strong> ont bien été pris en compte.</p>
|
|
|
+</li>
|
|
|
+</ol>
|
|
|
+<h3 id="test">Test</h3>
|
|
|
+<p>Nous allons faire un test de connexion :</p>
|
|
|
+<p><img alt="Page d'accueil de Debian" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-07%2008-34-27.png" /></p>
|
|
|
+<p>Tout fonctionne comme il faut.</p>
|
|
|
+<h2 id="creation-de-la-page-daccueil">Création de la page d'accueil</h2>
|
|
|
+<h3 id="la-page-daccueil">La page d'accueil</h3>
|
|
|
+<p>Nous allons créer un petit fichier <strong>.html</strong> pour personnaliser notre page d'acceuil. Le fichier s'appellera <strong>index.html</strong> et est situé dans <strong>/var/www/html/</strong>.</p>
|
|
|
+<pre><code>pi@piras:~ $ cd /var/www/html/
|
|
|
+pi@piras:/var/www/html $ ls
|
|
|
+index.html
|
|
|
+pi@piras:/var/www/html $
|
|
|
+</code></pre>
|
|
|
+<p>Avec votre éditeur favori, supprimez le fichier :</p>
|
|
|
+<pre><code>pi@piras:/var/www/html $ sudo rm index.html
|
|
|
+pi@piras:/var/www/html $
|
|
|
+</code></pre>
|
|
|
+<p>et créez un nouveau fichier dont le contenu est le suivant :</p>
|
|
|
+<pre><code><!DOCTYPE html>
|
|
|
+<html>
|
|
|
+ <head>
|
|
|
+ <title>Page d'accueil du Piras</title>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <h1>Page d'acceuil du Piras</h1>
|
|
|
+ <p>Vous voilà sur la page principale de notre tout nouveau serveur Web.</p>
|
|
|
+ <p>Merci de votre visite!</p>
|
|
|
+ </body>
|
|
|
+</html>
|
|
|
+
|
|
|
+pi@piras:/var/www/html $ sudo vim index.html
|
|
|
+pi@piras:/var/www/html $
|
|
|
+</code></pre>
|
|
|
+<p>Changez le propriétaire du fichier :</p>
|
|
|
+<pre><code>pi@piras:/var/www/html $ sudo chown www-data: index.html
|
|
|
+pi@piras:/var/www/html $
|
|
|
+</code></pre>
|
|
|
+<h3 id="creation-du-virtualhost-correspondant">Création du <strong>virtualhost</strong> correspondant</h3>
|
|
|
+<pre><code>pi@piras:/etc/apache2/sites-available $ cat piras.conf
|
|
|
+<VirtualHost *:80>
|
|
|
+
|
|
|
+ ServerName piras.yojik.net
|
|
|
+ ServerAdmin webmaster@localhost
|
|
|
+ DocumentRoot /var/www/html
|
|
|
+
|
|
|
+ ErrorLog ${APACHE_LOG_DIR}/error.log
|
|
|
+ CustomLog ${APACHE_LOG_DIR}/access.log combined
|
|
|
+
|
|
|
+</VirtualHost>
|
|
|
+pi@piras:/etc/apache2/sites-available $
|
|
|
+</code></pre>
|
|
|
+<p>On désactive les anciens sites par défaut, et on active le nouveau :</p>
|
|
|
+<pre><code>pi@piras:/etc/apache2/sites-available $ sudo a2dissite default-ssl
|
|
|
+Site default-ssl disabled.
|
|
|
+To activate the new configuration, you need to run:
|
|
|
+systemctl reload apache2
|
|
|
+pi@piras:/etc/apache2/sites-available $ sudo a2dissite 000-default
|
|
|
+Site 000-default disabled.
|
|
|
+To activate the new configuration, you need to run:
|
|
|
+systemctl reload apache2
|
|
|
+pi@piras:/etc/apache2/sites-available $
|
|
|
+
|
|
|
+pi@piras:/etc/apache2/sites-available $ sudo a2ensite piras
|
|
|
+Enabling site piras.
|
|
|
+To activate the new configuration, you need to run:
|
|
|
+systemctl reload apache2
|
|
|
+pi@piras:/etc/apache2/sites-available $
|
|
|
+</code></pre>
|
|
|
+<p>On recharge apache2 pour qu'il prenne en compte nos modifications :</p>
|
|
|
+<pre><code>pi@piras:/etc/apache2/sites-available $ sudo systemctl reload apache2
|
|
|
+pi@piras:/etc/apache2/sites-available $
|
|
|
+</code></pre>
|
|
|
+<h3 id="test-de-notre-page-daccueil">Test de notre page d'accueil</h3>
|
|
|
+<p><img alt="Page d'accueil du Piras" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-07%2009-04-24.png" /></p>
|
|
|
+<p>Et voilà! :D</p>
|
|
|
+<h2 id="securisation-de-notre-serveur">Sécurisation de notre serveur</h2>
|
|
|
+<h3 id="etat-des-lieux">État des lieux</h3>
|
|
|
+<p>Rendez-vous sur la page suivante : <a href="https://observatory.mozilla.org/">Test Mozilla</a>. Nos résultats ne sont pas terribles ...</p>
|
|
|
+<p><img alt="Résultat 1" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-07%2009-15-59.png" /></p>
|
|
|
+<p><img alt="Résultat 2" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-07%2009-16-17.png" /></p>
|
|
|
+<p><img alt="Résultat 3" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-07%2009-16-52.png" /></p>
|
|
|
+<p>Nous allons suivre les recommandations de la fondation <strong>Mozilla</strong> en ce qui concerne les algorithmes utilisés pour le chiffrement.</p>
|
|
|
+<p>Page de configuration d'un serveur Apache par la fondation <strong>Mozilla</strong> : <a href="https://ssl-config.mozilla.org/#server=apache&version=2.4.41&config=intermediate&openssl=1.1.1d&guideline=5.6">Configurateur</a></p>
|
|
|
+<p>Nous alons donc éditer notre fichier <strong>piras.conf</strong> situé dans <strong>/etc/apache2/sites-available/</strong> ainsi que le fichier général de configuration d'apache, situé dans pi@piras:/etc/apache2, <strong>apache2.conf</strong> :</p>
|
|
|
+<ol>
|
|
|
+<li>
|
|
|
+<p>Sauvegarde des fichiers existants</p>
|
|
|
+<p>pi@piras:/etc/apache2 $ sudo cp apache2.conf apache2.conf.orig
|
|
|
+pi@piras:/etc/apache2 $</p>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>Création de certificats let'encrypt</p>
|
|
|
+<p>Il existe plusieurs clients <strong>letsencrypt</strong> pour la gestion des certificats. Nous utiliserons <strong>certbot</strong>, le client officiel de <strong>letsencrypt</strong>.</p>
|
|
|
+<pre><code>pi@piras:~ $ sudo apt install certbot python-certbot-apache
|
|
|
+...
|
|
|
+pi@piras:~ $
|
|
|
+</code></pre>
|
|
|
+<p>Nous stoppons le service <strong>apache</strong></p>
|
|
|
+<pre><code>pi@piras:~ $ sudo systemctl stop apache2
|
|
|
+pi@piras:~ $
|
|
|
+</code></pre>
|
|
|
+<p>Lançons <strong>certbot</strong></p>
|
|
|
+<pre><code>pi@piras:~ $ sudo certbot
|
|
|
+Saving debug log to /var/log/letsencrypt/letsencrypt.log
|
|
|
+Plugins selected: Authenticator apache, Installer apache
|
|
|
+Enter email address (used for urgent renewal and security notices) (Enter 'c' to
|
|
|
+cancel): eric@yojik.eu
|
|
|
+
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+Please read the Terms of Service at
|
|
|
+https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
|
|
|
+agree in order to register with the ACME server at
|
|
|
+https://acme-v02.api.letsencrypt.org/directory
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+(A)gree/(C)ancel: A
|
|
|
+
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+Would you be willing to share your email address with the Electronic Frontier
|
|
|
+Foundation, a founding partner of the Let's Encrypt project and the non-profit
|
|
|
+organization that develops Certbot? We'd like to send you email about our work
|
|
|
+encrypting the web, EFF news, campaigns, and ways to support digital freedom.
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+(Y)es/(N)o: Y
|
|
|
+
|
|
|
+Which names would you like to activate HTTPS for?
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+1: piras.yojik.net
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+Select the appropriate numbers separated by commas and/or spaces, or leave input
|
|
|
+blank to select all options shown (Enter 'c' to cancel): 1
|
|
|
+Obtaining a new certificate
|
|
|
+Performing the following challenges:
|
|
|
+http-01 challenge for piras.yojik.net
|
|
|
+Waiting for verification...
|
|
|
+Cleaning up challenges
|
|
|
+Created an SSL vhost at /etc/apache2/sites-available/piras-le-ssl.conf
|
|
|
+Deploying Certificate to VirtualHost /etc/apache2/sites-available/piras-le-ssl.conf
|
|
|
+Enabling available site: /etc/apache2/sites-available/piras-le-ssl.conf
|
|
|
+
|
|
|
+Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+1: No redirect - Make no further changes to the webserver configuration.
|
|
|
+2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
|
|
|
+new sites, or if you're confident your site works on HTTPS. You can undo this
|
|
|
+change by editing your web server's configuration.
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
|
|
|
+Redirecting vhost in /etc/apache2/sites-enabled/piras.conf to ssl vhost in /etc/apache2/sites-available/piras-le-ssl.conf
|
|
|
+
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+Congratulations! You have successfully enabled https://piras.yojik.net
|
|
|
+
|
|
|
+You should test your configuration at:
|
|
|
+https://www.ssllabs.com/ssltest/analyze.html?d=piras.yojik.net
|
|
|
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+
|
|
|
+IMPORTANT NOTES:
|
|
|
+- Congratulations! Your certificate and chain have been saved at:
|
|
|
+/etc/letsencrypt/live/piras.yojik.net/fullchain.pem
|
|
|
+Your key file has been saved at:
|
|
|
+/etc/letsencrypt/live/piras.yojik.net/privkey.pem
|
|
|
+Your cert will expire on 2021-06-05. To obtain a new or tweaked
|
|
|
+version of this certificate in the future, simply run certbot again
|
|
|
+with the "certonly" option. To non-interactively renew *all* of
|
|
|
+your certificates, run "certbot renew"
|
|
|
+- Your account credentials have been saved in your Certbot
|
|
|
+configuration directory at /etc/letsencrypt. You should make a
|
|
|
+secure backup of this folder now. This configuration directory will
|
|
|
+also contain certificates and private keys obtained by Certbot so
|
|
|
+making regular backups of this folder is ideal.
|
|
|
+- If you like Certbot, please consider supporting our work by:
|
|
|
+
|
|
|
+Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
|
|
|
+Donating to EFF: https://eff.org/donate-le
|
|
|
+
|
|
|
+pi@piras:~ $
|
|
|
+</code></pre>
|
|
|
+<p>Relançons <strong>apache</strong></p>
|
|
|
+<pre><code>pi@piras:~ $ sudo systemctl start apache2
|
|
|
+pi@piras:~ $
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>Premier test</p>
|
|
|
+<p><img alt="Test avec SSL" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-07%2015-24-01.png" /></p>
|
|
|
+<p>C'est bon.</p>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>Sécurisation du serveur <strong>apache</strong></p>
|
|
|
+<ul>
|
|
|
+<li>
|
|
|
+<p>Strict-Transport-Security</p>
|
|
|
+<p>Ajouter la ligne suivante à piras.conf :</p>
|
|
|
+<pre><code>Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>Content-Security-Policy</p>
|
|
|
+<p>Ajouter la ligne suivante à piras.conf :</p>
|
|
|
+<pre><code>Header set Content-Security-Policy "default-src 'self';"
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>X-Content-Type-Options</p>
|
|
|
+<p>Ajouter la ligne suivante à piras.conf :</p>
|
|
|
+<pre><code><IfModule mod_headers.c>
|
|
|
+ Header set X-Content-Type-Options "nosniff"
|
|
|
+</IfModule>
|
|
|
+</code></pre>
|
|
|
+<p>Il faut activer aussi le module headers (déjà activé chez moi) :</p>
|
|
|
+<pre><code>pi@piras:~ $ sudo a2enmod headers
|
|
|
+Module headers already enabled
|
|
|
+pi@piras:~ $
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>X-Frame-Options</p>
|
|
|
+<p>Ajouter la ligne suivante à piras.conf :</p>
|
|
|
+<pre><code><IfModule mod_headers.c>
|
|
|
+ Header set X-Content-Type-Options "nosniff"
|
|
|
+</IfModule>
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>X-XSS-Protection</p>
|
|
|
+<p>Ajouter la ligne suivante à piras.conf :</p>
|
|
|
+<pre><code>Header set X-Frame-Options: "SAMEORIGIN"
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+</ul>
|
|
|
+<p>Voilà le contenu du fichier après modifications :</p>
|
|
|
+<pre><code>pi@piras:~ $ cat /etc/apache2/sites-available/piras-le-ssl.conf
|
|
|
+
|
|
|
+<IfModule mod_ssl.c>
|
|
|
+<VirtualHost *:443>
|
|
|
+ Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
|
|
+ Header set Content-Security-Policy "default-src 'self';"
|
|
|
+
|
|
|
+ <IfModule mod_headers.c>
|
|
|
+ Header set X-Content-Type-Options "nosniff"
|
|
|
+ </IfModule>
|
|
|
+
|
|
|
+ Header set X-Frame-Options: "SAMEORIGIN"
|
|
|
+
|
|
|
+ ServerName piras.yojik.net
|
|
|
+ ServerAdmin webmaster@localhost
|
|
|
+ DocumentRoot /var/www/html
|
|
|
+
|
|
|
+ ErrorLog ${APACHE_LOG_DIR}/error.log
|
|
|
+ CustomLog ${APACHE_LOG_DIR}/access.log combined
|
|
|
+
|
|
|
+SSLCertificateFile /etc/letsencrypt/live/piras.yojik.net/fullchain.pem
|
|
|
+SSLCertificateKeyFile /etc/letsencrypt/live/piras.yojik.net/privkey.pem
|
|
|
+Include /etc/letsencrypt/options-ssl-apache.conf
|
|
|
+</VirtualHost>
|
|
|
+</IfModule>
|
|
|
+
|
|
|
+pi@piras:~ $
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+</ol>
|
|
|
+<h3 id="test-de-notre-nouvelle-configuration">Test de notre nouvelle configuration</h3>
|
|
|
+<p>Cette fois-ci, nous obtenons la note maximale A+ :</p>
|
|
|
+<p><img alt="Test avec SSL" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-07%2018-13-31.png" /></p>
|
|
|
+<p><img alt="Test avec SSL" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-07%2018-13-51.png" /></p>
|
|
|
+<p><img alt="Test avec SSL" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-07%2018-14-43.png" /></p>
|
|
|
+<p>Nous sommes passés d'une note <strong>F</strong> à <strong>A+</strong>!</p>
|
|
|
+<h3 id="petites-ameliorations-supplementaires">Petites améliorations supplémentaires</h3>
|
|
|
+<ul>
|
|
|
+<li>
|
|
|
+<p>cacher les données du serveur</p>
|
|
|
+<p>Cela se configure dans le fichier <strong>/etc/apache2/conf-available/security.conf</strong></p>
|
|
|
+<p>J'ai modifié les lignes suivantes : </p>
|
|
|
+<pre><code>ServerSignature Off
|
|
|
+ServerTokens Prod
|
|
|
+</code></pre>
|
|
|
+<p>Sauvegarde du fichier et relance du serveur apache.</p>
|
|
|
+<p><img alt="Avant" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-08%2009-18-18.png" /></p>
|
|
|
+<p><img alt="Après" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-08%2009-18-28.png" /></p>
|
|
|
+<p>On peut constater que notre serveur ne divulgue plus d'informations sur son type, ni sur l'OS utilisé.</p>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>le parcours des répertoires</p>
|
|
|
+<p>Nous allons interdire le parcours des répertoires/sous-répertoires, de telle façon que le visiteur ne puisse plus voir les fichiers/répertoires.</p>
|
|
|
+<p>Procédure de test : </p>
|
|
|
+<p>Nous allons créer un répertoire <strong>test</strong> avec 2 fichiers (vides) dans l'arboresence de notre site Web.</p>
|
|
|
+<pre><code>pi@piras:/etc/apache2/conf-available $ cd /var/www/html/
|
|
|
+pi@piras:/var/www/html $ sudo mkdir test
|
|
|
+pi@piras:/var/www/html $ cd test
|
|
|
+pi@piras:/var/www/html/test $ sudo touch fichier1 fichier2
|
|
|
+pi@piras:/var/www/html/test $
|
|
|
+</code></pre>
|
|
|
+<p>Le résultat est le suivant :</p>
|
|
|
+<p><img alt="Avant" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-08%2009-25-25.png" /></p>
|
|
|
+<p>Retournons dans notre fichier précédent et modifions-le pour avoir ceci :</p>
|
|
|
+<pre><code><Directory /var/www/html>
|
|
|
+# AllowOverride None
|
|
|
+# Require all denied
|
|
|
+ Options None
|
|
|
+</Directory>
|
|
|
+</code></pre>
|
|
|
+<p>Relançons apache et voyons le résultat :</p>
|
|
|
+<p><img alt="Après" src="../../../Images/tutoraspi/Capture%20d%E2%80%99%C3%A9cran%20de%202021-03-08%2009-31-20.png" /></p>
|
|
|
+<p>Le visiteur n'a plus accès au listage des répertoires.</p>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>protection contre les informations données par l'entête (header) <strong>Etag</strong></p>
|
|
|
+<p>Il nous faut rajouter la directive suivante au fichier de configuration :</p>
|
|
|
+<pre><code>FileEtag None
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>limitation des requêtes possibles : </p>
|
|
|
+<p>les méthodes supportées sont nombreuses et peuvent être configurées site par site. Mais en général, pour un site statique comme celui-là, seules les méthodes <strong>GET</strong>, <strong>Head</strong>, et <strong>POST</strong> sont nécessaires.</p>
|
|
|
+<p>Modification du fichier précédent</p>
|
|
|
+<pre><code><Directory /var/www/html>
|
|
|
+# AllowOverride None
|
|
|
+# Require all denied
|
|
|
+ Options None
|
|
|
+ <LimitExcept GET POST OPTIONS>
|
|
|
+ Require all denied
|
|
|
+ </LimitExcept>
|
|
|
+</Directory>S
|
|
|
+</code></pre>
|
|
|
+</li>
|
|
|
+<li>
|
|
|
+<p>interdire la requête Trace</p>
|
|
|
+<p>C'est déjà mis en place par défaut dans la configuration Debian.</p>
|
|
|
+</li>
|
|
|
+</ul>
|
|
|
+<p>Voilà pour quelques améliorations de la sécurité de notre serveur Web.</p>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <footer>
|
|
|
+
|
|
|
+ <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
+
|
|
|
+ <a href="../Annexe/" class="btn btn-neutral float-right" title="Annexe">Next <span class="icon icon-circle-arrow-right"></span></a>
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../Installation-courrier-basique/" class="btn btn-neutral" title="Installation d'un serveur de courriers basique"><span class="icon icon-circle-arrow-left"></span> Previous</a>
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <hr/>
|
|
|
+
|
|
|
+ <div role="contentinfo">
|
|
|
+ <!-- Copyright etc -->
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+ Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
+</footer>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </section>
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="rst-versions" role="note" aria-label="versions">
|
|
|
+ <span class="rst-current-version" data-toggle="rst-current-version">
|
|
|
+
|
|
|
+
|
|
|
+ <span><a href="../Installation-courrier-basique/" style="color: #fcfcfc;">« Previous</a></span>
|
|
|
+
|
|
|
+
|
|
|
+ <span style="margin-left: 15px"><a href="../Annexe/" style="color: #fcfcfc">Next »</a></span>
|
|
|
+
|
|
|
+ </span>
|
|
|
+</div>
|
|
|
+ <script>var base_url = '../../..';</script>
|
|
|
+ <script src="../../../js/theme.js" defer></script>
|
|
|
+ <script src="../../../search/main.js" defer></script>
|
|
|
+ <script defer>
|
|
|
+ window.onload = function () {
|
|
|
+ SphinxRtdTheme.Navigation.enable(true);
|
|
|
+ };
|
|
|
+ </script>
|
|
|
+
|
|
|
+</body>
|
|
|
+</html>
|