aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStephen Muth <smuth4@gmail.com>2017-07-08 00:01:03 +0000
committerStephen Muth <smuth4@gmail.com>2017-07-08 00:01:03 +0000
commitb80315e2384a92e7a7ea8c3a6d4b38957851061b (patch)
tree22c3fdd69877eec444b4eb5231df58af2aa1c135
parent70cb883547a04b3ccd3fda567d15541d124a3f41 (diff)
downloadShaarli-b80315e2384a92e7a7ea8c3a6d4b38957851061b.tar.gz
Shaarli-b80315e2384a92e7a7ea8c3a6d4b38957851061b.tar.zst
Shaarli-b80315e2384a92e7a7ea8c3a6d4b38957851061b.zip
Respect HTTP_X_FORWARDED_HOST
alongside _PORT and _PROTO Fixes #879
-rw-r--r--application/HttpUtils.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/application/HttpUtils.php b/application/HttpUtils.php
index a81f9056..88a1efdb 100644
--- a/application/HttpUtils.php
+++ b/application/HttpUtils.php
@@ -311,7 +311,19 @@ function server_url($server)
311 } 311 }
312 } 312 }
313 313
314 return $scheme.'://'.$server['SERVER_NAME'].$port; 314 if (isset($server['HTTP_X_FORWARDED_HOST'])) {
315 // Keep forwarded host
316 if (strpos($server['HTTP_X_FORWARDED_HOST'], ',') !== false) {
317 $hosts = explode(',', $server['HTTP_X_FORWARDED_HOST']);
318 $host = trim($hosts[0]);
319 } else {
320 $host = $server['HTTP_X_FORWARDED_HOST'];
321 }
322 } else {
323 $host = $server['SERVER_NAME'];
324 }
325
326 return $scheme.'://'.$host.$port;
315 } 327 }
316 328
317 // SSL detection 329 // SSL detection