]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/HttpUtils.php
Fixes #477: support multi reverse proxy with comma syntax
[github/shaarli/Shaarli.git] / application / HttpUtils.php
index e2c1cb470f8a9c776358046839b10d3cdbdd3fd5..af7cb37123fa06a84738a6054c733ab0b38afd23 100644 (file)
@@ -106,11 +106,21 @@ function server_url($server)
     // Shaarli is served behind a proxy
     if (isset($server['HTTP_X_FORWARDED_PROTO'])) {
         // Keep forwarded scheme
-        $scheme = $server['HTTP_X_FORWARDED_PROTO'];
+        if (strpos($server['HTTP_X_FORWARDED_PROTO'], ',') !== false) {
+            $schemes = explode(',', $server['HTTP_X_FORWARDED_PROTO']);
+            $scheme = trim($schemes[0]);
+        } else {
+            $scheme = $server['HTTP_X_FORWARDED_PROTO'];
+        }
 
         if (isset($server['HTTP_X_FORWARDED_PORT'])) {
             // Keep forwarded port
-            $port = ':'.$server['HTTP_X_FORWARDED_PORT'];
+            if (strpos($server['HTTP_X_FORWARDED_PORT'], ',') !== false) {
+                $ports = explode(',', $server['HTTP_X_FORWARDED_PORT']);
+                $port = ':' . trim($ports[0]);
+            } else {
+                $port = ':' . $server['HTTP_X_FORWARDED_PORT'];
+            }
         }
 
         return $scheme.'://'.$server['SERVER_NAME'].$port;