summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-02-24 12:24:55 +0100
committerLukas Reschke <lukas@owncloud.com>2015-02-24 12:24:55 +0100
commit1c6eae90173b2b323a8e4633cda5f37eafa5a1d4 (patch)
treee7121f8edcb0d9d537e91d9ca20e947613bbba41 /lib
parente08ebe87dcd748deecba52714cf2711095671475 (diff)
downloadnextcloud-server-1c6eae90173b2b323a8e4633cda5f37eafa5a1d4.tar.gz
nextcloud-server-1c6eae90173b2b323a8e4633cda5f37eafa5a1d4.zip
Get the real protocol behind several proxies
X-Forwarded-Proto contains a list of protocols if ownCloud is behind multiple reverse proxies. This is a revival of https://github.com/owncloud/core/pull/11157 using the new IRequest public API.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/appframework/http/request.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php
index 959ea273280..f415d6faf2e 100644
--- a/lib/private/appframework/http/request.php
+++ b/lib/private/appframework/http/request.php
@@ -480,8 +480,8 @@ class Request implements \ArrayAccess, \Countable, IRequest {
}
/**
- * Returns the server protocol. It respects reverse proxy servers and load
- * balancers.
+ * Returns the server protocol. It respects one or more reverse proxies servers
+ * and load balancers
* @return string Server protocol (http or https)
*/
public function getServerProtocol() {
@@ -491,7 +491,13 @@ class Request implements \ArrayAccess, \Countable, IRequest {
}
if (isset($this->server['HTTP_X_FORWARDED_PROTO'])) {
- $proto = strtolower($this->server['HTTP_X_FORWARDED_PROTO']);
+ if (strpos($this->server['HTTP_X_FORWARDED_PROTO'], ',') !== false) {
+ $parts = explode(',', $this->server['HTTP_X_FORWARDED_PROTO']);
+ $proto = strtolower(trim(current($parts)));
+ } else {
+ $proto = strtolower($this->server['HTTP_X_FORWARDED_PROTO']);
+ }
+
// Verify that the protocol is always HTTP or HTTPS
// default to http if an invalid value is provided
return $proto === 'https' ? 'https' : 'http';