kb:linux:apache2:reverse_proxy_avec_https
Ceci est une ancienne révision du document !
Reverse Proxy avec HTTPS
Installation et Configuration
Il faut évidemment installer Apache2 pour effectuer la manipulation
# apt-get install apache2
Puis activer les mods Apache2 pour effectuer le Reverse Proxy et le HTTPS
# a2enmod proxy # a2enmod proxy_http # a2enmod rewrite # a2enmod ssl # a2enmod headers
Puis on désactive les sites par défaut
# a2dissite 000-default.conf # a2dissite default-tls.conf
Puis il reste juste à créer la configuration du site
# nano /etc/apache2/site-available/monsite.conf
Et rentré ceci avec les modifications adéquates
<VirtualHost *:443>
#########GENERAL#########
ServerName domain.tld
###########SSL###########
# Il est nécessaire d'activer SSL, sinon c'est http qui sera utilisé
SSLEngine On
# Les clefs du serveur :
SSLCertificateFile /path/to/key/fullchain.pem
SSLCertificateKeyFile /path/to/key/privkey.pem
# On autorise TLSv1.2, on rejette les autres
SSLProtocol -all +TLSv1.2
# On autorise uniquement les clefs de cryptage longue (high).
SSLCipherSuite HIGH:!kRSA:!kDHr:!kDHd:!kSRP:!aNULL:!3DES:!MD5
# On fournit l'entête HSTS
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
##########PROXY##########
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
<IfModule mod_rewrite.c>
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://domain.lan/
ProxyPassReverse / http://domain.lan/
RewriteRule ^/(.*) http://domain.lan/$1 [P,L]
</IfModule>
</IfModule>
<Location />
Order deny,allow
Allow from all
</Location>
###########LOG###########
ErrorLog /var/log/apache2/domain.tld-error.log
LogLevel warn
CustomLog /var/log/apache2/domain.tld-access.log combined
</VirtualHost>
# Redirection des requettes HTTP vers l'HTTPS.
<VirtualHost *:80>
ServerName domain.tld
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^{TRACE|TRACK}
RewriteRule .* - [F]
</IfModule>
Redirect permanent / https://domain.tld/
###########LOG###########
ErrorLog /var/log/apache2/domain.tld-error.log
LogLevel warn
CustomLog /var/log/apache2/domain.tld-access.log combined
</VirtualHost>
Il suffira d'acitiver le site
# a2ensite monsite.conf
puis de relancer apache2
# service apache2 restart
Et le tour est joué
kb/linux/apache2/reverse_proxy_avec_https.1495637359.txt.gz · Dernière modification : (modification externe)
