diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index faa42dc2bd4a78231564aba6045347b79a2b0410..2f22f272206cc10ddbe14b73a545abcb3d72d6d3 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -1736,16 +1736,6 @@ function test_valeur_serveur($truc) { * racine de SPIP : par exemple, sur ecrire/ elle vaut 1, sur sedna/ 1, et à * la racine 0. Sur url/perso/ elle vaut 2 * - * @note - * Le test indiquant une connexion 'https' repose sur plusieurs éléments en fonction - * des serveurs / reverse proxy. Dans certains cas il faut compléter en indiquant à SPIP - * que le port 80 d'arrivée est aussi utilisé pour https, sinon il ajoutera :80 aux urls calculées. - * - * ``` - * // Nginx:443 => Apache:80 => SPIP… - * define('_PORT_HTTPS_STANDARD', '443,80'); - * ``` - * * @param int|boo|array $profondeur * - si non renseignée : retourne l'url pour la profondeur $GLOBALS['profondeur_url'] * - si int : indique que l'on veut l'url pour la profondeur indiquée @@ -1772,7 +1762,7 @@ function url_de_base($profondeur = null) { } $http = 'http'; - // plusieurs configurations serveurs peuvent indiquer une connexion https + if ( isset($_SERVER["SCRIPT_URI"]) and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' @@ -1783,12 +1773,6 @@ function url_de_base($profondeur = null) { and test_valeur_serveur($_SERVER['HTTPS']) ) { $http = 'https'; - } elseif ( - isset($_SERVER['HTTP_X_FORWARDED_PROTO']) - AND $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' - AND strncmp($GLOBALS['meta']['adresse_site'], 'https', 5) == 0) - { - $http = 'https'; } // note : HTTP_HOST contient le :port si necessaire diff --git a/ecrire/inc_version.php b/ecrire/inc_version.php index 88fda3bed4fb5a4082e7c9f9cbd858961f455a1d..0a7eae0f50b3ab3782464cb6592aadd90962985a 100644 --- a/ecrire/inc_version.php +++ b/ecrire/inc_version.php @@ -209,6 +209,14 @@ $debut_date_publication = null; // // Prendre en compte les entetes HTTP_X_FORWARDED_XX // +if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO']==='https'){ + if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { + $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; + } + if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { + $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; + } +} if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])){ if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])){ $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT'];