diff options
author | Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net> | 2012-09-09 12:54:47 +0200 |
---|---|---|
committer | herbrechtsmeier <stefan@herbrechtsmeier.net> | 2013-01-31 18:42:31 +0100 |
commit | ab2b79cda682a697baba2128a21d3a9b5e90853c (patch) | |
tree | fbaf5a643bbfa2c4236d574ecb41784f5c859d15 /lib/request.php | |
parent | 411e8e5218e0b0d6dc7e993f283b8a457f780af9 (diff) | |
download | nextcloud-server-ab2b79cda682a697baba2128a21d3a9b5e90853c.tar.gz nextcloud-server-ab2b79cda682a697baba2128a21d3a9b5e90853c.zip |
add multiple domains reverse proxy support
Add support for a reverse proxy that handles multiple domains via different
web roots (http[s]://proxy.tld/domain.tld/owncloud).
As the reverse proxy web root is transparent for the web server the
REQUEST_URI and SCRIPT_NAME need manual adjustments. This patch replace
the direct use of this _SERVER variables with function calls and extend
this functions to overwrite the web root. Additionally it adds a Sabre
request backend that extends the Sabre_HTTP_Request to use the same
functions.
Diffstat (limited to 'lib/request.php')
-rwxr-xr-x | lib/request.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/request.php b/lib/request.php index f2f15c21103..4c056ce9b2f 100755 --- a/lib/request.php +++ b/lib/request.php @@ -59,6 +59,38 @@ class OC_Request { } /** + * @brief Returns the request uri + * @returns the request uri + * + * Returns the request uri, even if the website uses one or more + * reverse proxies + */ + public static function requestUri() { + $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; + if (OC_Config::getValue('overwritewebroot', '') <> '') { + $uri = self::scriptName() . substr($uri, strlen($_SERVER['SCRIPT_NAME'])); + } + return $uri; + } + + /** + * @brief Returns the script name + * @returns the script name + * + * Returns the script name, even if the website uses one or more + * reverse proxies + */ + public static function scriptName() { + $name = $_SERVER['SCRIPT_NAME']; + if (OC_Config::getValue('overwritewebroot', '') <> '') { + $serverroot = str_replace("\\", '/', substr(__DIR__, 0, -4)); + $suburi = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen($serverroot))); + $name = OC_Config::getValue('overwritewebroot', '') . $suburi; + } + return $name; + } + + /** * @brief get Path info from request * @returns string Path info or false when not found */ |