Skip to content
Snippets Groups Projects
Commit d4f98923 authored by Stefan Herbrechtsmeier's avatar Stefan Herbrechtsmeier
Browse files

Overwrite host and webroot when forcessl is enabled

This patch enables the use of forcessl together with a multiple domains
reverse SSL proxy (owncloud/core#1099) which have different hostname
and webroot for http and https access. The code assumes that the ssl
proxy (https) hostname and webroot is configured via overwritehost and
overwritewebroot.
parent 0629ff4d
Branches
No related tags found
No related merge requests found
...@@ -11,9 +11,10 @@ class OC_Request { ...@@ -11,9 +11,10 @@ class OC_Request {
* @brief Check overwrite condition * @brief Check overwrite condition
* @returns true/false * @returns true/false
*/ */
private static function isOverwriteCondition() { private static function isOverwriteCondition($type = '') {
$regex = '/' . OC_Config::getValue('overwritecondaddr', '') . '/'; $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));
} }
/** /**
...@@ -52,7 +53,7 @@ class OC_Request { ...@@ -52,7 +53,7 @@ class OC_Request {
* Returns the server protocol. It respects reverse proxy servers and load balancers * Returns the server protocol. It respects reverse proxy servers and load balancers
*/ */
public static function serverProtocol() { 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'); return OC_Config::getValue('overwriteprotocol');
} }
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment