Add "trusted_proxy" option

Fixes #188
This commit is contained in:
Dmitriy Simushev 2017-03-09 13:34:57 +00:00
parent e718518698
commit 8b1e218862
2 changed files with 13 additions and 0 deletions

View File

@ -77,6 +77,15 @@ default_locale: en
# http://php.net/manual/en/timezones.php
timezone: ""
# List of proxy's IP Mibew should trust. You should set this option if you use
# Mibew with a load balancer or behind a proxy.
trusted_proxies: []
# Here is an example of what values this option can take:
# trusted_proxies:
# - 127.0.0.1
# - ::1
# - 10.0.0.0/8
# Plugins
plugins: []

View File

@ -44,6 +44,10 @@ require_once(MIBEW_FS_ROOT . '/libs/common/request.php');
require_once(MIBEW_FS_ROOT . '/libs/common/response.php');
require_once(MIBEW_FS_ROOT . '/libs/common/string.php');
if (count($configs['trusted_proxies']) > 0) {
\Symfony\Component\HttpFoundation\Request::setTrustedProxies($configs['trusted_proxies']);
}
// We need to get some info from the request. Use symfony wrapper because it's
// the simplest way.
$tmp_request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();