From e50bbd1ba8ad7fb1543bb23ac84cf2c091bcb202 Mon Sep 17 00:00:00 2001 From: Rain Ramm Date: Wed, 28 Dec 2016 14:00:19 +0200 Subject: [PATCH] Fix url proxy support --- src/BitWeb/ErrorReporting/Service/ErrorService.php | 2 +- test/BitWebTest/ErrorReporting/Service/ErrorServiceTest.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BitWeb/ErrorReporting/Service/ErrorService.php b/src/BitWeb/ErrorReporting/Service/ErrorService.php index b74291f..1e29402 100644 --- a/src/BitWeb/ErrorReporting/Service/ErrorService.php +++ b/src/BitWeb/ErrorReporting/Service/ErrorService.php @@ -253,7 +253,7 @@ public function getUrl() { if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { $prefix = (array_key_exists('HTTP_X_FORWARDED_PROTO', $_SERVER) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ? 'https://' : 'http://'; - $domain = $_SERVER['HTTP_X_FORWARDED_FOR']; + $domain = $_SERVER['HTTP_HOST']; } else { $prefix = (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] === 'on') ? 'https://' : 'http://'; $domain = $_SERVER['SERVER_NAME']; diff --git a/test/BitWebTest/ErrorReporting/Service/ErrorServiceTest.php b/test/BitWebTest/ErrorReporting/Service/ErrorServiceTest.php index cc937e9..ede19a1 100644 --- a/test/BitWebTest/ErrorReporting/Service/ErrorServiceTest.php +++ b/test/BitWebTest/ErrorReporting/Service/ErrorServiceTest.php @@ -213,7 +213,8 @@ public function testGetUrlWithHttp() public function testGetUrlWithXForwardedFor() { - $_SERVER['HTTP_X_FORWARDED_FOR'] = 'bitweb.ee'; + $_SERVER['HTTP_HOST'] = 'bitweb.ee'; + $_SERVER['HTTP_X_FORWARDED_FOR'] = '127.0.0.1'; $_SERVER['SERVER_NAME'] = 'localhost'; $_SERVER['REQUEST_URI'] = '/error-reporting';