Skip to content
Extraits de code Groupes Projets
Valider 999523ad rédigé par cerdic's avatar cerdic
Parcourir les fichiers

Fix #3386 : gerer le host reel vs le host vu par PHP en cas de reverse proxy a...

Fix #3386 : gerer le host reel vs le host vu par PHP en cas de reverse proxy a l'aide de HTTP_X_FORWARDED_HOST
parent 4e6f4361
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -1540,13 +1540,20 @@ function url_de_base($profondeur=null) {
OR (isset($_SERVER['HTTPS']) AND
test_valeur_serveur($_SERVER['HTTPS']))
) ? 'https' : 'http';
# note : HTTP_HOST contient le :port si necessaire
$host = $_SERVER['HTTP_HOST'];
if (isset($_SERVER['SERVER_PORT'])
AND $port=$_SERVER['SERVER_PORT']
AND strpos($host,":")==false){
if ($http=="http" AND $port!=80) $host.=":$port";
if ($http=="https" AND $port!=443) $host.=":$port";
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])){
$host = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"' \r\n", '________');
}
else {
# note : HTTP_HOST contient le :port si necessaire
$host = $_SERVER['HTTP_HOST'];
if (isset($_SERVER['SERVER_PORT'])
AND $port=$_SERVER['SERVER_PORT']
AND strpos($host,":")==false){
if (!defined('_PORT_HTTP_STANDARD')) define('_PORT_HTTP_STANDARD','80');
if (!defined('_PORT_HTTPS_STANDARD')) define('_PORT_HTTPS_STANDARD','443');
if ($http=="http" AND !in_array($port,explode(',',_PORT_HTTP_STANDARD))) $host.=":$port";
if ($http=="https" AND !in_array($port,explode(',',_PORT_HTTPS_STANDARD))) $host.=":$port";
}
}
if (!$GLOBALS['REQUEST_URI']){
if (isset($_SERVER['REQUEST_URI'])) {
......
......@@ -194,6 +194,10 @@ function calculer_contexte_implicite(){
'notes' => $notes?$notes('','contexter_cache'):'',
'spip_version_code' => $GLOBALS['spip_version_code'],
);
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])){
$contexte_implicite['host'] .= "|" . $_SERVER['HTTP_X_FORWARDED_HOST'];
}
return $contexte_implicite;
}
......
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