diff -ru t3lib.411.original/class.t3lib_div.php t3lib.411.reverseproxypatch/class.t3lib_div.php --- t3lib.411.original/class.t3lib_div.php 2007-04-14 11:45:06.436670400 +0200 +++ t3lib.411.reverseproxypatch/class.t3lib_div.php 2007-04-14 13:03:56.077560000 +0200 @@ -3007,6 +3007,63 @@ } /** + * This patch should not be used in a productive environment. + * + * Wrapper method (Version 0.06 from 2007/04/14) + * for old getIndpEnv that has been renamed to getIndpEnvClassic + * This patch should not be used in a productive environment. + * + * This function serves as a temporary workaround to enable + * SSL proxy support in TYPO3 4.1.1. You have to change the value + * of $sslProxyIP manually to the IP address of you reverse proxy. + * + * More information regarding this method you will find here: + * http://www.henningpingel.de/TYPO3-Backend-Via-SSL-Proxy.124.0.html + */ + function getIndpEnv($getEnvName) { + $sslProxyIP = '0.0.0.0'; //fill in the local IP address of your SSL proxy here + $retVal = ''; + if ($_SERVER["REMOTE_ADDR"] == $sslProxyIP && $_SERVER["HTTP_X_FORWARDED_HOST"] != ''){ // && TYPO3_MODE=='BE'){ + $sslProxy_folder = $_SERVER['HTTP_HOST']; + $sslProxy_host = $_SERVER['HTTP_X_FORWARDED_HOST']; + switch ((string)$getEnvName) { + case 'HTTP_HOST': + $retVal = $sslProxy_host; + break; + case 'SCRIPT_NAME': + case 'REQUEST_URI': + $retVal = '/' . $sslProxy_folder . t3lib_div::getIndpEnvClassic($getEnvName); + break; + case 'TYPO3_REQUEST_HOST': + $retVal = 'https://'. $sslProxy_host; //this is now forced to https, this is a problem if reverse proxy does not use SSL + break; + case 'TYPO3_SSL': + $retVal = TRUE;//this is now forced to https, but this means a problem if the reverse proxy does not use SSL + break; + case 'TYPO3_HOST_ONLY': + $p = explode(':',$sslProxy_host); + $retVal = $p[0]; + break; + case 'TYPO3_PORT': + $p = explode(':',$sslProxy_host); + $retVal = $p[1]; + break; + case 'REMOTE_ADDR': + $retVal = $_SERVER["HTTP_X_FORWARDED_FOR"]; //this contains ip address of enduser, REMOTE_ADDR contains IP of proxy + break; + default: + $retVal = t3lib_div::getIndpEnvClassic($getEnvName); + } + } + else{ + $retVal = t3lib_div::getIndpEnvClassic($getEnvName); + } + //error_log("debug getIndpEnv case :" . $getEnvName . " - " . $retVal); //enable this for debugging purpose + + return $retVal; + } + + /** * Abstraction method which returns System Environment Variables regardless of server OS, CGI/MODULE version etc. Basically this is SERVER variables for most of them. * This should be used instead of getEnv() and $_SERVER/ENV_VARS to get reliable values for all situations. * Usage: 221 @@ -3014,7 +3071,7 @@ * @param string Name of the "environment variable"/"server variable" you wish to use. Valid values are SCRIPT_NAME, SCRIPT_FILENAME, REQUEST_URI, PATH_INFO, REMOTE_ADDR, REMOTE_HOST, HTTP_REFERER, HTTP_HOST, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE, QUERY_STRING, TYPO3_DOCUMENT_ROOT, TYPO3_HOST_ONLY, TYPO3_HOST_ONLY, TYPO3_REQUEST_HOST, TYPO3_REQUEST_URL, TYPO3_REQUEST_SCRIPT, TYPO3_REQUEST_DIR, TYPO3_SITE_URL, _ARRAY * @return string Value based on the input key, independent of server/os environment. */ - function getIndpEnv($getEnvName) { + function getIndpEnvClassic($getEnvName) { /* Conventions: output from parse_url(): @@ -3284,7 +3341,9 @@ function getHostname($requestHost=TRUE) { $host = ''; if ($requestHost && (!defined('TYPO3_cliMode') || !TYPO3_cliMode)) { - $host = $_SERVER['HTTP_HOST']; + //$host = $_SERVER['HTTP_HOST']; //old version, why is getIndpEnv not used for this??? + $host = getIndpEnv('HTTP_HOST'); + //error_log("hepi: getHostname was called"); //enable this for debugging purposes } if (!$host) { // will fail for PHP 4.1 and 4.2