Skip to content
Extraits de code Groupes Projets
Valider a5bcaa7b rédigé par marcimat's avatar marcimat
Parcourir les fichiers

Correction différente pour #3386 (Cerdic) afin de regrouper les choses autour...

Correction différente pour #3386 (Cerdic) afin de regrouper les choses autour de HTTP_X_FORWARDED au même endroit.
parent d3db3e7f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -1736,16 +1736,6 @@ function test_valeur_serveur($truc) { ...@@ -1736,16 +1736,6 @@ function test_valeur_serveur($truc) {
* racine de SPIP : par exemple, sur ecrire/ elle vaut 1, sur sedna/ 1, et à * racine de SPIP : par exemple, sur ecrire/ elle vaut 1, sur sedna/ 1, et à
* la racine 0. Sur url/perso/ elle vaut 2 * 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 * @param int|boo|array $profondeur
* - si non renseignée : retourne l'url pour la profondeur $GLOBALS['profondeur_url'] * - 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 * - si int : indique que l'on veut l'url pour la profondeur indiquée
...@@ -1772,7 +1762,7 @@ function url_de_base($profondeur = null) { ...@@ -1772,7 +1762,7 @@ function url_de_base($profondeur = null) {
} }
$http = 'http'; $http = 'http';
// plusieurs configurations serveurs peuvent indiquer une connexion https
if ( if (
isset($_SERVER["SCRIPT_URI"]) isset($_SERVER["SCRIPT_URI"])
and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https'
...@@ -1783,12 +1773,6 @@ function url_de_base($profondeur = null) { ...@@ -1783,12 +1773,6 @@ function url_de_base($profondeur = null) {
and test_valeur_serveur($_SERVER['HTTPS']) and test_valeur_serveur($_SERVER['HTTPS'])
) { ) {
$http = '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 // note : HTTP_HOST contient le :port si necessaire
......
...@@ -209,6 +209,14 @@ $debut_date_publication = null; ...@@ -209,6 +209,14 @@ $debut_date_publication = null;
// //
// Prendre en compte les entetes HTTP_X_FORWARDED_XX // 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_HOST'])){
if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])){ if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])){
$_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter