Installation et sécurisation d'une station Debian 3.0 stable15/05/2004 
  
	
	
	
	
	 
	 IV. INSTALLATION ET SECURISATION D'UN SERVEUR APACHE MODSSL
			
			
			 IV.a. IV.a. Installation
				
					
					
					
					
					
				
				 IV.b. Configuration initiale
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
				
				 IV.c. Integration des quotas
					
					
					
				
				 IV.d. Empreinte du système
					
					
				
				 IV.e. Sauvegarde du système
					
					
				
			
	
  
	
	
	
	
	 
	
 IV. INSTALLATION ET SECURISATION D'UN SERVEUR APACHE MODSSL 
  
			
			
				Les actions réalisées  ici  ont  été  réalisées  après  avoir  suivi  les  étapes
				suivantes de la procédure générale :
				
					
						1. INSTALLATION DU SYSTEME
					
					
						2. CONFIGURATION INITIALE DU SYSTEME
					
					
						3. PREMIER ACCES AU SYSTEME ET SECURISATION MINIMALE
					
					
						4. SECURISATION MODEREE
					
					
						5.4. Gestion des quotas
					
					
						5.5. Sécurisation PAM : Gestion des limites
					
				
			  
			
 
  
				
					
						Vous devez avoir une partition /dev/sda11 dans /etc/fstab du type :
					  
					/dev/sda11  /var/www ext2   rw,nosuid,nodev 0  2  
					apt-get update
apt-get install apache apache-doc libapache-mod-ssl libapache-mod-ssl-doc -d  
					
						=> Acceptez les packages: 'apache apache-common apache-doc libapache-mod-ssl
						libapache-mod-ssl-doc libexpat1 openssl'.
					  
					cd /var/cache/apt/archives/
for i in `echo *.deb` ; do md5sum $i;done
    98146bac67cff4cf252e4ff2bbbb6560  apache-common_1.3.26-0woody3_i386.deb
    a13fce3a93f137ef243bc743e7b5a57d  apache-doc_1.3.26-0woody3_all.deb
    95d81b2239554383c56c7d193c476ddb  apache_1.3.26-0woody3_i386.deb
    7c5f6a20d23ec97bd7d0f8ec5bd14172  libapache-mod-ssl-doc_2.8.9-2.1_all.deb
    9756a3701103f8779c65455c968898c3  libapache-mod-ssl_2.8.9-2.1_i386.deb
    95f921ff15b8bf124ec9e9e6a3230774  libexpat1_1.95.2-6_i386.deb
    8af019bb8fc566504db03d88f75b782a  openssl_0.9.6c-2.woody.2_i386.deb
  
mount -o remount,rw /usr/
mount -o remount,exec /tmp/
apt-get install apache apache-doc libapache-mod-ssl libapache-mod-ssl-doc
mount -o remount,ro /usr/
mount -o remount,noexec /tmp/
/etc/init.d/apache stop  
				
				
 IV.b. Configuration initiale 
  
					
					
						Ajoutez les règles suivantes à votre firewall et rechargez le :
					  
					# Allow anyone to reach us on HTTP/HTTPS tcp ports
$IPCH -A input -p tcp --sport 1024: --dport 80 -j ACCEPT
$IPCH -A output -p tcp --sport 80 --dport 1024: -j ACCEPT  
					
						Créez une arborescence :
					  
					mkdir /var/www/htdocs
chmod 750 /var/www/htdocs && chown root:www-data /var/www/htdocs  
					
						Positionnez des permissions restrictives sur la configuration :
					  
					chmod 750 /etc/apache /etc/apache/ssl*
chmod 640 /etc/apache/*.conf  
					
						Préparez le certificat (ou récuperez le votre) :
					  
					mkdir /etc/apache/ssl
cd /etc/apache/ssl
openssl genrsa -out {HOSTNAME}.key 2048
openssl req -new -x509 -days 365 -key m18412.key -out m18412.crt  
					
						Mettez en place un fichier de configuration minimal :
					  
					cd /etc/apache
cp httpd.conf httpd.conf.orig  
					
						Remplacez /etc/apache/httpd.conf par le fichier de configuration présent  en
						'ANNEXE 6 - Fichier de configuration Apache minimal'. 
						 
						Créez le groupe webadm: groupadd webadm 
						 
						Préparez le répertoire de logs :
					  
					mkdir /var/log/apache
chown root:webadm /var/log/apache && chmod 3750 /var/log/apache  
					
						Préparez la rotation des logs en modifiant le fichier  /etc/logrotate.d/apache
						sur les lignes suivantes (Vous devriez  adapter  cette  configuration  à votre
						environnement en créant un script d'archivage dans un répertoire distinct) :
					  
					daily
rotate 365
create 640 root webadm  
					
						Démarrez et testez Apache : 
					  
					/etc/init.d/apache start  
					
						Ajoutez vos utilisateurs/administrateurs dans un groupe  webadm  qui  aura des
						droits sur l'arborescence web : groupadd webadm 
						 
						Pour les administrateurs: usermod -g {UserName} -G adm,users,webadm,www-data
						{UserName} 
						Pour les utilisateurs : usermod -g users -G webadm,www-data {UserName} 
						 
						Avec 'visudo', ajoutez les entrées suivantes dans /etc/sudoers pour  permettre
						à vos administrateurs web d'administrer le serveur Apache :
					  
					# Cmnd alias specification
[...]
Cmnd_Alias      APACHECTL=/usr/sbin/apachectl
[...]
# User privilege specification
[...]      
%webadm    ALL=NOPASSWD:APACHECTL  
					
						L'arborescence des sous-répertoires de 'htdocs' peut être du type :
					  
					mkdir /var/www/htdocs/{directory_name}
chown root:webadm /var/www/htdocs/{directory_name}
chmod 3775 /var/www/htdocs/{directory_name}  
					
						Vos administrateurs web (groupes webadm et www-data) peuvent désormais accéder
						à cette arborescence et poser les  fichiers  nécessaires  au  site  des facons
						suivantes :
						
							
								{UserName}:webadm => Par défaut
							
							
								{UserName}:www-data => Avec un chown.
								=> Attention, dans les deux cas  aux  permissions  affectées  aux  fichiers,
								elles doivent au moins être en 644 pour le premier cas et en 640 pour  le
								second cas.
							
						
					  
				
				
 IV.c. Integration des quotas 
  
					
					Groupe    Partition  Place  Soft  Hard  Inodes   Soft  Hard 
adm	      /tmp        185M   50M   60M     49K    15K   20K
adm	      /home	  465M  100M  125M    122K    20K   30K
adm	      /var/www	  279M     1     1       1      1     1
users     /tmp        185M   50M   60M     49K    15K   20K
users     /home	  465M  100M  125M    122K    10K   15K
users     /var/www	  279M     1     1       1      1     1
webadm    /tmp        185M     1     1     49K      1     1
webadm    /home	  465M  100M  125M    122K    10K   15K
webadm    /var/www	  279M  200M  225M     73K    50K   60K
www-data  /tmp        185M     1     1     49K      1     1
www-data  /home	  465M     1     1    122K      1     1
www-data  /var/www	  279M   40M   50M     73K     1K   10K  
					Utilisateur  Partition  Place  Soft  Hard  Inodes   Soft  Hard 
quotauser	 /tmp        185M    5M   10M     49K   1,5K    5K
quotauser	 /home       465M   15M	  20M    122K     3K    5K
quotauser	 /var/www    279M    5M   10M     73K     1K    2K  
				
				
 IV.d. Empreinte du système 
  
					
					
						Suivez la procédure présentée en '5.3. Conserver une empreinte de vérification
						d'intégrité du système.'
					  
				
				
 IV.e. Sauvegarde du système 
  
					
					
						Référez vous à '4.11. Backup du système sur une partition spécifique'.
					  
				
			
	
 
 
		Copyright (c) 2003 Simon Castro, scastro [ at ] entreelibre.com. 
		 
		Permission is granted to copy, distribute and/or modify this document under the
		terms of the GNU Free Documentation License, Version 1.2  or  any later version
		published by the Free Software Foundation; with  the  Invariant  Sections being
		LIST THEIR  TITLES,  with  the  Front-Cover  Texts  being  LIST, and   with the
		Back-Cover Texts being LIST. 
		You must have received a copy of the license with this document and  it  should
		be présent in the fdl.txt file.  
		If you did not receive this file or if you don't think this  fdl.txt license is
		correct,  have  a  look  on  the  official  http://www.fsf.org/licenses/fdl.txt
		licence file.
	 
       |