Différences

Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.

Lien vers cette vue

linux:serveur_web [2011/10/19 23:15]
matthieu
linux:serveur_web [2011/12/01 23:37] (Version actuelle)
matthieu [Links]
Ligne 1: Ligne 1:
 {{tag>fr fr:linux fr:serveur fr:web}} {{tag>fr fr:linux fr:serveur fr:web}}
-====== Serveur Web ======+====== Serveur Web (Apache) ======
 Quelle que soit le but de votre serveur, un service web est très souvent indispensable. Quelle que soit le but de votre serveur, un service web est très souvent indispensable.
  
Ligne 19: Ligne 19:
  
  
-===== Configuration =====+===== Principe de configuration =====
 La configuration d'Apache2 est définie par le fichier ///etc/apache2/apache2.conf//. C'est un fichier à plat mais il inclue d'autres fichiers grâce à la commande Include : La configuration d'Apache2 est définie par le fichier ///etc/apache2/apache2.conf//. C'est un fichier à plat mais il inclue d'autres fichiers grâce à la commande Include :
   * /etc/apache2/apache2.conf   * /etc/apache2/apache2.conf
Ligne 44: Ligne 44:
 </code> </code>
  
-[[linux:serveur_web:config]] +===== Configuration avancée =====
- +
- +
- +
- +
-===== Configuration de l'HTTPS ===== +
-Cette partie décrit l'activation de l'HTTPS dans Apache2. +
- +
- +
-==== Création du certificat ==== +
- +
-Pour générer le certificat, voir [[Openssl]]. +
- +
-Copier ensuite la clé privée ainsi que le certificat dans un fichier pem et le placer par exemple dans ///etc/apache2/ssl///. +
- +
- +
-==== Ouverture des ports ==== +
-Afin d'activer l'HTTPS, il faut que apache écoute le port 443. Pour cela il suffit de l'ajouter au fichier ///etc/apache2/ports.conf// : +
-<file> +
-Listen 80 +
-Listen 443 +
-</file> +
- +
- +
-==== Activation du module ==== +
-Il faut ensuite activer le module ssl : +
- +
-<code> +
-bender:/etc/apache2# a2enmod ssl +
-Module ssl installed; run /etc/init.d/apache2 force-reload to enable. +
-bender:/etc/apache2# /etc/init.d/apache2 force-reload +
-Forcing reload of web server (apache2)... waiting . +
-bender:/etc/apache2# +
-</code> +
- +
- +
-==== Configuration du ssl ==== +
-Pour finir, il faut configurer un virtual host avec le moteur SSL activé. +
- +
-Exemple de configuration : +
-<file> +
-NameVirtualHost *:443 +
-<VirtualHost *:443> +
-        SSLEngine on +
-        SSLCertificateFile /etc/apache2/ssl/mat.homeftp.org.pem +
- +
-        ServerAdmin webmaster@localhost +
- +
-        DocumentRoot /var/www/ +
-        <Directory /> +
-                Options FollowSymLinks +
-                AllowOverride None +
-        </Directory> +
-        <Directory /var/www/> +
-                Options Indexes FollowSymLinks MultiViews +
-                AllowOverride None +
-                Order allow,deny +
-                allow from all +
-                # This directive allows us to have apache2's default start page +
-                # in /apache2-default/, but still have / go to the right place +
-                RedirectMatch ^/$ /apache2-default/ +
-        </Directory> +
- +
-        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ +
-        <Directory "/usr/lib/cgi-bin"> +
-                AllowOverride None +
-                Options ExecCGI -MultiViews +SymLinksIfOwnerMatch +
-                Order allow,deny +
-                Allow from all +
-        </Directory> +
- +
-        ErrorLog /var/log/apache2/error.log +
- +
-        # Possible values include: debug, info, notice, warn, error, crit, +
-        # alert, emerg. +
-        LogLevel warn +
- +
-        CustomLog /var/log/apache2/access.log combined +
-        ServerSignature On +
- +
-    Alias /doc/ "/usr/share/doc/" +
-    <Directory "/usr/share/doc/"> +
-        Options Indexes MultiViews FollowSymLinks +
-        AllowOverride None +
-        Order deny,allow +
-        Deny from all +
-        Allow from 127.0.0.0/255.0.0.0 ::1/128 +
-    </Directory> +
- +
-</VirtualHost> +
-</file> +
- +
-Voici les principales directives pour le module SSL : +
- +
-=== SSLEngine === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslengine| +
-^Description|Active ou désactive me moteur SSL| +
-^Syntaxe    |%%SSLEngine on|off|optional%%| +
-^Contexte   |server config, virtual host| +
- +
-=== SSLCertificateFile === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslcertificatefile| +
-^Description|Indique le fichier contenant la clé et le certificat| +
-^Syntaxe    |SSLCertificateKeyFile file-path| +
-^Contexte   |server config, virtual host| +
- +
- +
- +
- +
-===== Authentification LDAP ===== +
-Ce paragraphe décrit comment configurer l'authentification LDAP dans Apache2. +
- +
-==== Installation ==== +
-Pour l'installation d'un serveur LDAP, voir [[openldap]]. +
- +
-L'authentification LDAP d'Apache2 est réalisée par le module authnz_ldap. Son activation se fait de la façon suivante : +
-<code> +
-bender:/etc/apache2# a2enmod authnz_ldap +
-Enabling ldap as a dependency +
-Module ldap installed; run /etc/init.d/apache2 force-reload to enable. +
-Module authnz_ldap installed; run /etc/init.d/apache2 force-reload to enable. +
-bender:/etc/apache2# +
-</code> +
- +
- +
- +
- +
- +
- +
- +
-==== Configuration ==== +
- +
-Voici un exemple d'authentification LDAP : +
-<file> +
-<Directory /home/ssl> +
-     AuthType basic +
-     AuthName "private area" +
-     AuthBasicProvider ldap +
-     AuthLDAPURL ldap://127.0.0.1/dc=matthieu,dc=bouthors,dc=org?cn?sub?(objectClass=*) +
-     AuthLDAPBindDN cn=apache,ou=services,dc=matthieu,dc=bouthors,dc=org +
-     AuthLDAPBindPassword *** +
-     AuthzLDAPAuthoritative off +
-     require ldap-group cn=web,ou=groups,dc=matthieu,dc=bouthors,dc=org +
-</Directory> +
-</file> +
- +
-Les principales directives à utiliser pour authentifier les utilisateurs en LDAP sont decrite ci-dessous. +
- +
- +
- +
-=== AuthType === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/core.html#authtype| +
-^Description|Définit le type d'authentification| +
-^Syntaxe    |%%AuthType Basic|Digest%%| +
-^Contexte   |directory, .htaccess| +
- +
-=== AuthName === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/core.html#authname| +
-^Description|Nom du royaume présenté à l'utilisateur| +
-^Syntaxe    |%%AuthName auth-domain%%| +
-^Contexte   |directory, .htaccess| +
- +
-=== AuthBasicProvider === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_auth_basic.html#authbasicprovider| +
-^Description|Indique le moteur d'authentification pour cette URL| +
-^Syntaxe    |%%AuthBasicProvider provider-name [provider-name] ...%%| +
-^Contexte   |directory, .htaccess| +
- +
-=== AuthLDAPURL === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authldapurl| +
-^Description|Définit les paramètres de recherche LDAP| +
-^Syntaxe    |%%AuthLDAPUrl ldap://host:port/basedn?attribute?scope?filter [NONE|SSL|TLS|STARTTLS]%%| +
-^Contexte   |directory, .htaccess| +
- +
-=== AuthLDAPBindDN === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authldapbinddn| +
-^Description|Définit le compte de service pour se connecter au LDAP (lorsque l'authentification anonyme est impossible).| +
-^Syntaxe    |%%AuthLDAPBindDN distinguished-name%%| +
-^Contexte   |directory, .htaccess| +
- +
-=== AuthLDAPBindPassword === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authldapbindpassword| +
-^Description|Définit le mot de passe du compte de service| +
-^Syntaxe    |%%AuthLDAPBindPassword password%%| +
-^Contexte   |directory, .htaccess| +
- +
-=== AuthzLDAPAuthoritative === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authzldapauthoritative| +
-^Description|Permet de contrôler si d'autre module d'authentification peuvent authentifier l'utilisateur en cas d'utilisateur introuvable dans le LDAP.| +
-^Syntaxe    |%%AuthzLDAPAuthoritative on|off%%| +
-^Contexte   |directory, .htaccess| +
- +
-=== Require === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#require| +
-^Description|Définit quelle personne authentifiée peut accèder à ce répertoire| +
-^Syntaxe    |Require entity-name [entity-name] ...| +
-^Contexte   |directory, .htaccess| +
- +
-Exemples : +
-  * N'importe quel utilisateur valide : +
- +
-  require valid-user +
- +
-  * L'utilisateur matthieu : +
- +
-  require matthieu +
- +
-  * Le groupe "web" : +
- +
-  require ldap-group cn=web,ou=groups,dc=matthieu,dc=bouthors,dc=org +
-===== Authentification MySQL ===== +
-Attention : la méthode décrite ci dessous ne fonctionne plus avec les dernières version de apache. +
-En effet le module utilisé n'est plus maintenu. +
- +
- +
- +
- +
-==== Installation ==== +
- +
-Pour l'installation de Mysql, voir [[mysql]].\\ +
-Pour construire la base de données contenant les utilisateurs, voir [[authent_sql]]. +
- +
-Le paquet suivant est nécessaire : +
-  * libapache2-auth-mysql +
- +
-Une fois installé, il suffit d'activer le module avec la commande suivante : +
-  a2enmod auth_mysql +
- +
-==== Configuration ==== +
-Voici un exemple de configuration avec l'authentification Mysql. +
- +
-Pour le descriptif des directives, voir http://www.diegonet.com/support/mod_auth_mysql.shtml +
- +
-<file> +
-# configuration authentification mysql (auth mysql) +
-Auth_MySQL_Info localhost apache ********* +
-Auth_MySQL_General_DB users +
- +
-        <Directory /> +
-                AllowOverride None +
-        +
-                Auth_MySQL_Password_Table users +
-                Auth_MySQL_Group_Table groupes_apache +
-                Auth_MySQL_Username_Field login +
-                Auth_MySQL_Password_Field password +
-                Auth_MySQL_Group_Field groupe +
-                Auth_MySQL_Empty_Passwords off +
-                Auth_MySQL_Encryption_Types Crypt +
-                Auth_MySQL_Authoritative on +
-                Auth_MySQL on +
- +
-                AuthType Basic +
-                AuthName Extranet_matthieu.bouthors.org +
-                Require group admin +
-                Order Deny,Allow +
-                Deny from All +
-        </Directory> +
- +
-        <Directory /home/ssl> +
-                Options Indexes FollowSymLinks MultiViews +
-                AllowOverride None +
-                Order allow,deny +
-                allow from all +
-                Require valid-user +
-        </Directory> +
-</file> +
- +
- +
-===== Encodage des caractères spéciaux ===== +
-Le fichier ///etc/apache2/conf.d/charset// définit le Content-Type renvoyé par Apache. +
- +
-Par défaut, il est en UTF8 : +
-<file> +
-AddDefaultCharset UTF-8 +
-</file> +
- +
-Pour configurer le serveur en ISO, il faut indiquer : +
-<file> +
-AddDefaultCharset ISO-8859-15 +
-</file> +
- +
- +
- +
-===== Configuration de PHP ===== +
- +
-Dans ///etc/php5/apache2/php.ini// configurer la taille maximum d'upload autorisé, par exemple : +
-  upload_max_filesize = 15M +
- +
  
 +Pour aller plus loin et configurer en détail Apache, voir les sous-parties suivantes :
 +  * [[linux:serveur_web:config]]
 +  * [[linux:serveur_web:ssl]]
 +  * [[linux:serveur_web:auth]]
  
  
Ligne 350: Ligne 66:
   * http://httpd.apache.org/docs/2.2/mod/mod_authn_dbd.html   * http://httpd.apache.org/docs/2.2/mod/mod_authn_dbd.html
   * http://apache.webthing.com/database/   * http://apache.webthing.com/database/
-  * http://www.diegonet.com/support/mod_auth_mysql.shtml+
  
  
  
linux/serveur_web.1319058930.txt.gz · Dernière modification: 2011/10/19 23:15 par matthieu
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki