diff options
author | Bart Visscher <bartv@thisnet.nl> | 2013-04-26 05:10:49 -0700 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2013-04-26 05:10:49 -0700 |
commit | 710acde9a112c7ff5bb1c3d93d7a52bab3fa821e (patch) | |
tree | a0b1d1a8b7e8b7cf5e680f9f01cdffd4b09af636 /lib | |
parent | 26e2672a5a35b8fa417b7f8650bede78f01b70d7 (diff) | |
parent | ecb9d37b55f5c55545a2c0ec475e22d71bd4dcc8 (diff) | |
download | nextcloud-server-710acde9a112c7ff5bb1c3d93d7a52bab3fa821e.tar.gz nextcloud-server-710acde9a112c7ff5bb1c3d93d7a52bab3fa821e.zip |
Merge pull request #1872 from herbrechtsmeier/forcessl-with-ssl-proxy
Overwrite host and webroot when forcessl is enabled
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/request.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/request.php b/lib/request.php index 9f74cf9beb5..4d8380eb9ac 100755 --- a/lib/request.php +++ b/lib/request.php @@ -11,9 +11,10 @@ class OC_Request { * @brief Check overwrite condition * @returns true/false */ - private static function isOverwriteCondition() { + private static function isOverwriteCondition($type = '') { $regex = '/' . OC_Config::getValue('overwritecondaddr', '') . '/'; - return $regex === '//' or preg_match($regex, $_SERVER['REMOTE_ADDR']) === 1; + return $regex === '//' or preg_match($regex, $_SERVER['REMOTE_ADDR']) === 1 + or ($type !== 'protocol' and OC_Config::getValue('forcessl', false)); } /** @@ -27,7 +28,7 @@ class OC_Request { if(OC::$CLI) { return 'localhost'; } - if(OC_Config::getValue('overwritehost', '')<>'' and self::isOverwriteCondition()) { + if(OC_Config::getValue('overwritehost', '') !== '' and self::isOverwriteCondition()) { return OC_Config::getValue('overwritehost'); } if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { @@ -52,7 +53,7 @@ class OC_Request { * Returns the server protocol. It respects reverse proxy servers and load balancers */ public static function serverProtocol() { - if(OC_Config::getValue('overwriteprotocol', '')<>'' and self::isOverwriteCondition()) { + if(OC_Config::getValue('overwriteprotocol', '') !== '' and self::isOverwriteCondition('protocol')) { return OC_Config::getValue('overwriteprotocol'); } if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { @@ -76,7 +77,7 @@ class OC_Request { */ public static function requestUri() { $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; - if (OC_Config::getValue('overwritewebroot', '') <> '' and self::isOverwriteCondition()) { + if (OC_Config::getValue('overwritewebroot', '') !== '' and self::isOverwriteCondition()) { $uri = self::scriptName() . substr($uri, strlen($_SERVER['SCRIPT_NAME'])); } return $uri; @@ -91,7 +92,7 @@ class OC_Request { */ public static function scriptName() { $name = $_SERVER['SCRIPT_NAME']; - if (OC_Config::getValue('overwritewebroot', '') <> '' and self::isOverwriteCondition()) { + if (OC_Config::getValue('overwritewebroot', '') !== '' and self::isOverwriteCondition()) { $serverroot = str_replace("\\", '/', substr(__DIR__, 0, -4)); $suburi = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen($serverroot))); $name = OC_Config::getValue('overwritewebroot', '') . $suburi; |