Ceci est une ancienne révision du document !
Cette page décrit l'activation de l'HTTPS dans Apache.
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/.
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
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#
Pour finir, il faut configurer un virtual host avec le moteur SSL activé.
Voici les principales directives pour le module SSL :
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 |
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 |
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>