diff --git a/.env.example b/.env.example index 63f81969dae6..2a6eb900debe 100644 --- a/.env.example +++ b/.env.example @@ -48,6 +48,7 @@ REQUIRE_HTTPS=false GOOGLE_MAPS_API_KEY= API_SECRET=superdoopersecrethere ERROR_EMAIL= +TRUSTED_PROXIES= NINJA_ENVIRONMENT=selfhost diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index d86aec22a8e8..82fd6890763e 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -13,6 +13,7 @@ namespace App\Http\Middleware; use Fideloper\Proxy\TrustProxies as Middleware; use Illuminate\Http\Request; +use Illuminate\Contracts\Config\Repository; class TrustProxies extends Middleware { @@ -29,4 +30,18 @@ class TrustProxies extends Middleware * @var int */ protected $headers = Request::HEADER_X_FORWARDED_ALL; + + /* + * Instantiate trusted proxies middleware + * + * @param \Illuminate\Contracts\Config\Repository $config + */ + public function __construct(Repository $config) { + + parent::__construct($config); + + if (config('ninja.trusted_proxies')) + $this->proxies = config('ninja.trusted_proxies'); + + } } diff --git a/config/ninja.php b/config/ninja.php index a32f6a39402d..c21ae376ba0f 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -29,7 +29,8 @@ return [ 'enabled_modules' => 32767, 'phantomjs_key' => env('PHANTOMJS_KEY', false), 'phantomjs_secret' => env('PHANTOMJS_SECRET', false), - + 'trusted_proxies' => env('TRUSTED_PROXIES', false), + 'sentry_dsn' => env('SENTRY_LARAVEL_DSN', 'https://9b4e15e575214354a7d666489783904a@sentry.invoicing.co/6'), 'environment' => env('NINJA_ENVIRONMENT', 'selfhost'), // 'hosted', 'development', 'selfhost', 'reseller'