128 lines
3.9 KiB
Markdown
128 lines
3.9 KiB
Markdown
Voici mes prises de notes pour configurer un site Internet **http**. Le configuration est destinée pour un site Internet commençant par **www**.
|
|
|
|
```
|
|
Configurer Apache 2
|
|
http:*www.abonnel.fr ==> https:*www.abonnel.fr <==[reverse-proxy]==> 54.1.23.4
|
|
```
|
|
|
|
## Pré requis
|
|
Je viens de demander un certificat SSL pour le site Internet. Il faut configurer Apache 2 pour que :
|
|
- les demandes en https utilisent le certificat SSL
|
|
- toutes les visites en http soit redirigé en https
|
|
|
|
# Configurer
|
|
Je complète le fichier de configuration `/etc/apache2/sites-available/100-com.perdu.extra.conf`. J'ajoute un bloc de redirection vers `https` :
|
|
|
|
```
|
|
RewriteEngine On
|
|
RewriteCond %{SERVER_NAME} =extra.perdu.com
|
|
RewriteCond %{REQUEST_URI} !\.well-known/acme-challenge/.*
|
|
RewriteRule ^ https:*%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
|
|
```
|
|
|
|
Puis, j'ajoute un bloc pour la configuration SSL / https. Il s'agit d'un copier/coller de la configuration http.
|
|
J'effectue quelques modifications :
|
|
- et pour l’écriture des fichiers logs
|
|
- pour la redirection des URL sans www
|
|
- Ajout des options SSL
|
|
- Ajout de la gestion des certificats
|
|
|
|
```
|
|
<IfModule mod_ssl.c>
|
|
<VirtualHost *:443>
|
|
|
|
ServerName extra.perdu.com
|
|
|
|
ProxyPreserveHost On
|
|
ProxyPass "/" "http:*103.224.182.253/"
|
|
ProxyPassReverse "/" "http:*103.224.182.253/"
|
|
|
|
Include /etc/letsencrypt/options-ssl-apache.conf
|
|
SSLCertificateFile /etc/letsencrypt/live/extra.perdu.com/fullchain.pem
|
|
SSLCertificateKeyFile /etc/letsencrypt/live/extra.perdu.com/privkey.pem
|
|
|
|
</VirtualHost>
|
|
</IfModule>
|
|
```
|
|
|
|
Les options SSL sont à créer une seule fois sur le serveur. Ces options sont communes à tous les sites Internet que je configure.
|
|
Les options dans `/etc/letsencrypt/options-ssl-apache.conf` sont les suivantes :
|
|
```
|
|
SSLEngine on
|
|
|
|
# intermediate configuration, tweak to your needs
|
|
SSLProtocol -ALL +TLSv1.2
|
|
SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:!RC4:HIGH:!MD5:!aNULL:!EDH
|
|
|
|
SSLHonorCipherOrder on
|
|
|
|
SSLCompression on
|
|
#SSLSessionTickets off
|
|
|
|
# -- Securité supplémentaire
|
|
|
|
SSLOptions +StrictRequire
|
|
|
|
# HSTS (mod_headers is required) (15768000 seconds = 6 months)
|
|
Header always set Strict-Transport-Security "max-age=15768000"
|
|
|
|
# Always ensure Cookies have "Secure" set (JAH 2012/1)
|
|
Header edit Set-Cookie (?i)^(.*)(;\s*secure)??[^note: \s*;)?(.*] "$1; Secure$3$4"
|
|
```
|
|
|
|
---
|
|
Ce qui donne une configuration globale suivante :
|
|
|
|
```
|
|
<VirtualHost *:80>
|
|
|
|
ServerName extra.perdu.com
|
|
|
|
# ProxyPass devient obsolète avec RewriteRule
|
|
ProxyPass /.well-known/acme-challenge !
|
|
Alias /.well-known/acme-challenge /var/www/html/.well-known/acme-challenge
|
|
|
|
<Directory "/var/www/html/.well-known/acme-challenge">
|
|
Options None
|
|
AllowOverride None
|
|
Require all granted
|
|
AddDefaultCharset off
|
|
</Directory>
|
|
|
|
# Proxy* deviennent obsolète avec Rewrite*
|
|
ProxyPreserveHost On
|
|
ProxyPass "/" "http:*103.224.182.253/"
|
|
ProxyPassReverse "/" "http:*103.224.182.253/"
|
|
|
|
RewriteEngine On
|
|
RewriteCond %{SERVER_NAME} =info.mindcast.fr
|
|
RewriteCond %{REQUEST_URI} !\.well-known/acme-challenge/.*
|
|
RewriteRule ^ https:*%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
|
|
|
|
</VirtualHost>
|
|
|
|
<IfModule mod_ssl.c>
|
|
<VirtualHost *:443>
|
|
|
|
ServerName extra.perdu.com
|
|
|
|
ProxyPreserveHost On
|
|
ProxyPass "/" "http:*103.224.182.253/"
|
|
ProxyPassReverse "/" "http:*103.224.182.253/"
|
|
|
|
Include /etc/letsencrypt/options-ssl-apache.conf
|
|
SSLCertificateFile /etc/letsencrypt/live/extra.perdu.com/fullchain.pem
|
|
SSLCertificateKeyFile /etc/letsencrypt/live/extra.perdu.com/privkey.pem
|
|
|
|
</VirtualHost>
|
|
</IfModule>
|
|
```
|
|
|
|
# Recharger
|
|
Après ces modifications, je recharge la configuration de Apache 2 :
|
|
```
|
|
sudo service apache2 reload
|
|
```
|
|
|
|
# Liens
|
|
https://stackoverflow.com/questions/20406845/proxy-error-502-the-proxy-server-received-an-invalid-response-from-an-upstream |