HTTPS avec Apache

Cette page décrit l'activation de l'HTTPS dans Apache.

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 :

Listen 80
Listen 443

Activation du module

Il faut ensuite activer le module ssl :

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#

Configuration du ssl

Pour finir, il faut configurer un virtual host avec le moteur SSL activé.
Voici les principales directives pour le module SSL :

  • SSLEngine : Active ou désactive me moteur SSL
  • SSLCertificateFile : Indique le fichier contenant la clé et le certificat
  • SSLCertificateChainFile : Indique le fichier contenant les éventuelles autorités intermédiaires

Exemple de configuration

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>

Links

linux/serveur_web/ssl.txt · Dernière modification: 2011/12/01 23:39 par matthieu
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki