Création d'un site sécurisé sous Apache et Aperçu de la CGI avec Python.
Structure du répertoire
Dans cette partie nous allons mettre en place 2 sites sur un server Apache.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Créer un hôte virtuel
- Créer les répertoires dans /var/www/
Création du Site 1
Créer de nouveaux fichiers d'hôtes virtuels
-
Créer un fichier d'hôte virtuel
nano /etc/apache2/sites-available/port_vhosts.conf
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Activer le nouveau fichier de l'hôte virtuel
-
Redémarrer le service Apache
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Testez les résultats
Sécurisation de base
-
Lorsqu'on essaye de naviguer sur une adresse eronnée, nous constatons que des données sensible concernant le server sont visible.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Nous allons donc masquer les informations.
nano /etc/apache2/conf-enabled/security.conf
- Désactiver : « #ServerTokens OS »
- Ajouter : « ServerTokens Prod »
- Activer : « ServerSignature Off »
- Désactiver : « #ServerSignature On »
- Activer : « TraceEnable Off »
- Déactiver : « #TraceEnable On »
-
Sur un navigateur Web :
http://192.168.64.133/t
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Le protocole TLS permet à deux machines de communiquer de manière sécurisée. Les informations échangées entre les deux machines sont de ce fait pratiquement inviolables. Il doit assurer l'authentification du serveur grâce à un certificat. La confidentialité des données grâce au chiffrement et l’intégrité des données.
-
Un certificat permet de fournir diverses informations concernant l'identité de son détenteur (la personne qui publie les données). Ce certificat s'accompagne d'une clé publique qui est indispensable pour que la communication entre les machines soit chiffrée.
-
Activer le module SSL d’Apache, Activer le site «default-ssl» d’Apache
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Installez le paquet OpenSSL
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Générer le certificat
-
Modifier les permissions sur la clé
chmod 440 /etc/apache2/server.crt
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Configuration d’Apache
/etc/apache2/sites-available/default-ssl
-
Modifiez ces deux options si nécessaire afin d’indiquer le chemin vers les fichiers, Suite aux dernières vulnérabilités découvertes au sein du protocole SSL en 2014, il est recommandé également d'effectuer la configuration suivante dans Apache pour plus de sécurité :
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
activez le module SSL
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Désactiver le site HTTP
a2dissite default
-
Rediriger le HTTP vers HTTPS automatiquement, modifier le fichier suivant
nano /etc/apache2/sites-available/port_vhosts.conf
-
Dans le virtualhost, ajoutez la ligne suivante :
Redirect permanent / https://192.168.64.133/site1
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Redémarrer le service Apache2
service apache2 reload
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Vous pouvez remarquer que lorsque vous allez naviguer sur http://192.168.64.133, le site vous redirigera vers https://192.168.64.133/site1

-
Cliquer sur accéder à la page web

Protéger une page web avec .htaccess
-
Créer un fichier .htaccess dans le répertoire /var/www/vhosts/site1/
nano /var/www/vhosts/site1/.htaccess
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Créer le fichier ".htpasswd"
htpasswd -c /var/www/site/.htpasswd nom_utilisateur
-
Consulter le fichier .htpasswd
cat /var/www/vhosts/site1/.htpasswd
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Modifier la configuration d'Apache
nano /etc/apache2/apache2.conf
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Rendre publique une sous-partie du site protégé
mkdir /var/www/vhosts/site1/open nano /var/www/vhosts/site1/open/.htaccess
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Lors de connexion sur https://192.168.64.133/site1

-
Lors de connexion sur https://192.168.64.133/site1/open

Aperçu de la CGI avec Python
-
Modifier le fichier de configuration Apache
nano /etc/apache2/apache2.conf
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Activer le module CGI
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Nous allons maintenant créer une page index.py sur le site 2
nano /var/www/vhosts/site2/index.py
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Résultats :
-
Nous allons maintenant créer un formulaire
nano /var/www/vhosts/site2/formulaire.py
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Résultats :
-
Créer un fichier livredor.py
nano /var/www/vhosts/site2/livredor.py
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Résultats :

-
Créer un fichier compteur.py
nano /var/www/vhosts/site2/compteur.py
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Résultats :
-
1ère visite

-
50ème visite
