[Typo3-dev] [patch] reverse proxy support
Willem van Engen
wvengen at stack.nl
Thu Jul 3 11:12:26 CEST 2003
Hi,
after installing typo3 I discovered it doesn't support a reverse-proxy
setup where the php-requests are handled by a second server running on
localhost and the first server forwarding all php requests to the second
server. The patch below solves it. Beware, I only tested it with my
setup, but it should work otherwise.
I have to note that it still lacks some things, e.g. logging of
ip-adresses goes wrong (think REMOTE_ADDR).
- Willem van Engen
p.s. I'm not on this list, so when replying, please don't forget to add me.
diff -ruN t3lib/class.t3lib_div.php t3lib/class.t3lib_div.php
--- t3lib/class.t3lib_div.php Wed Feb 12 17:17:04 2003
+++ t3lib/class.t3lib_div.php Wed Jul 2 11:20:04 2003
@@ -1611,12 +1611,17 @@
case "REMOTE_ADDR":
case "REMOTE_HOST":
case "HTTP_REFERER":
- case "HTTP_HOST":
case "HTTP_USER_AGENT":
case "HTTP_ACCEPT_LANGUAGE":
case "QUERY_STRING":
return $HTTP_SERVER_VARS[$getEnvName];
break;
+ case "HTTP_HOST":
+ if (isset($HTTP_SERVER_VARS["HTTP_X_FORWARDED_HOST"]))
+ return $HTTP_SERVER_VARS["HTTP_X_FORWARDED_HOST"];
+ else
+ return $HTTP_SERVER_VARS["HTTP_HOST"];
+
case "TYPO3_DOCUMENT_ROOT":
// Some CGI-versions (LA13CGI) and mod-rewrite rules on MODULE versions will deliver a "wrong" DOCUMENT_ROOT (according to our description). Further various aliases/mod_rewrite rules can disturb this as well.
// Therefore the DOCUMENT_ROOT is now always calculated as the SCRIPT_FILENAME minus the end part shared with SCRIPT_NAME.
@@ -1634,16 +1639,16 @@
return $DR;
break;
case "TYPO3_HOST_ONLY":
- $p=explode(":",$HTTP_SERVER_VARS["HTTP_HOST"]);
+ $p=explode(":",t3lib_div::getIndpEnv("HTTP_HOST"));
return $p[0];
break;
case "TYPO3_PORT":
- $p=explode(":",$HTTP_SERVER_VARS["HTTP_HOST"]);
+ $p=explode(":",t3lib_div::getIndpEnv("HTTP_HOST"));
return $p[1];
break;
case "TYPO3_REQUEST_HOST":
return "http".($HTTP_SERVER_VARS["SSL_SESSION_ID"]?"s":"")."://". // I hope this: ($HTTP_SERVER_VARS["SSL_SESSION_ID"]?"s":"") - is sufficient to detect https...
- $HTTP_SERVER_VARS["HTTP_HOST"];
+ t3lib_div::getIndpEnv("HTTP_HOST");
break;
case "TYPO3_REQUEST_URL":
return t3lib_div::getIndpEnv("TYPO3_REQUEST_HOST").t3lib_div::getIndpEnv("REQUEST_URI");
@@ -1669,6 +1674,7 @@
// Here, list ALL possible keys to this function for debug display.
$envTestVars = t3lib_div::trimExplode(",","
HTTP_HOST,
+ HTTP_X_FORWARDED_HOST,
TYPO3_HOST_ONLY,
TYPO3_PORT,
PATH_INFO,
More information about the TYPO3-dev
mailing list