aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/HttpUtils.php
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2016-03-01 12:15:10 +0100
committerArthur <arthur@hoa.ro>2016-03-01 12:15:10 +0100
commit6e7a3210c3ec2b70b748d513bbd5168a887bf0ea (patch)
tree0513dad3f290e1e5d41c0760d24aa96a7590c2ce /application/HttpUtils.php
parent8710d4da8e21b31a90bdcaed10521e0b937cf6c2 (diff)
parent85244fa0d06eec620f8476817f68d8ea2dca0e38 (diff)
downloadShaarli-6e7a3210c3ec2b70b748d513bbd5168a887bf0ea.tar.gz
Shaarli-6e7a3210c3ec2b70b748d513bbd5168a887bf0ea.tar.zst
Shaarli-6e7a3210c3ec2b70b748d513bbd5168a887bf0ea.zip
Merge pull request #505 from ArthurHoaro/hotfix/multi-reverse-proxy
Fixes #477: support multi reverse proxy with comma syntax
Diffstat (limited to 'application/HttpUtils.php')
-rw-r--r--application/HttpUtils.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/application/HttpUtils.php b/application/HttpUtils.php
index e2c1cb47..af7cb371 100644
--- a/application/HttpUtils.php
+++ b/application/HttpUtils.php
@@ -106,11 +106,21 @@ function server_url($server)
106 // Shaarli is served behind a proxy 106 // Shaarli is served behind a proxy
107 if (isset($server['HTTP_X_FORWARDED_PROTO'])) { 107 if (isset($server['HTTP_X_FORWARDED_PROTO'])) {
108 // Keep forwarded scheme 108 // Keep forwarded scheme
109 $scheme = $server['HTTP_X_FORWARDED_PROTO']; 109 if (strpos($server['HTTP_X_FORWARDED_PROTO'], ',') !== false) {
110 $schemes = explode(',', $server['HTTP_X_FORWARDED_PROTO']);
111 $scheme = trim($schemes[0]);
112 } else {
113 $scheme = $server['HTTP_X_FORWARDED_PROTO'];
114 }
110 115
111 if (isset($server['HTTP_X_FORWARDED_PORT'])) { 116 if (isset($server['HTTP_X_FORWARDED_PORT'])) {
112 // Keep forwarded port 117 // Keep forwarded port
113 $port = ':'.$server['HTTP_X_FORWARDED_PORT']; 118 if (strpos($server['HTTP_X_FORWARDED_PORT'], ',') !== false) {
119 $ports = explode(',', $server['HTTP_X_FORWARDED_PORT']);
120 $port = ':' . trim($ports[0]);
121 } else {
122 $port = ':' . $server['HTTP_X_FORWARDED_PORT'];
123 }
114 } 124 }
115 125
116 return $scheme.'://'.$server['SERVER_NAME'].$port; 126 return $scheme.'://'.$server['SERVER_NAME'].$port;