From 1c4204fbec11f170d4aa369fb6bc352e11b112b7 Mon Sep 17 00:00:00 2001 From: lpoujol Date: Thu, 27 Oct 2022 17:32:48 +0200 Subject: [PATCH] Reverse proxy --- HowtoDrupal.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/HowtoDrupal.md b/HowtoDrupal.md index c4c437f4..b617e968 100644 --- a/HowtoDrupal.md +++ b/HowtoDrupal.md @@ -115,6 +115,31 @@ $ drush sql-connect $ drush status ~~~ +### Configuration derrière un reverse-proxy + +Dans la configuration de drupal, des directives sont à activer pour la prise en compte des headers HTTP X-Forwarded-For). + +~~~php +$settings['reverse_proxy'] = TRUE; + +$settings['reverse_proxy_addresses'] = ['192.0.2.1']; +~~~ + +Pour le HTTPS (signalé via X-Forwarded-Proto), il y a déjà des directives de configuration pour prendre ce réglage en compte. +Elles ressemblent à : + +~~~php + /** + * If external request was HTTPS but internal request is HTTP, set $_SERVER['HTTPS'] so Drupal detects the right scheme. + */ + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && isset($_SERVER['REQUEST_SCHEME'])) { + if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' && $_SERVER["REQUEST_SCHEME"] == 'http') { + $_SERVER['HTTPS'] = 'on'; + } + } +~~~ + + ## Optimisation