Ceci est une ancienne révision du document !


HTTPS avec Apache

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 :

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é.

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>

Voici les principales directives pour le module SSL :

SSLEngine

Lien http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslengine
DescriptionActive 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
DescriptionIndique le fichier contenant la clé et le certificat
Syntaxe SSLCertificateKeyFile file-path
Contexte server config, virtual host
linux/serveur_web/ssl.1319059015.txt.gz · Dernière modification: 2011/10/19 23:16 par matthieu
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki