From 1837bf3f3e5b4aa92747e6a8175d631fc7b171d1 Mon Sep 17 00:00:00 2001 From: jayvirsinh_gohil Date: Mon, 24 May 2021 13:13:46 +0530 Subject: [PATCH] allow to customize trusted proxies --- .env.example | 2 ++ config/trustedproxy.php | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 config/trustedproxy.php diff --git a/.env.example b/.env.example index 6cccbc63..8e98cb86 100644 --- a/.env.example +++ b/.env.example @@ -34,3 +34,5 @@ PUSHER_SECRET= SANCTUM_STATEFUL_DOMAINS=crater.test SESSION_DOMAIN=crater.test + +TRUSTED_PROXIES="*" diff --git a/config/trustedproxy.php b/config/trustedproxy.php new file mode 100644 index 00000000..5d9d0fc6 --- /dev/null +++ b/config/trustedproxy.php @@ -0,0 +1,50 @@ + null, // [,], '*', ',' + + /* + * To trust one or more specific proxies that connect + * directly to your server, use an array or a string separated by comma of IP addresses: + */ + // 'proxies' => ['192.168.1.1'], + // 'proxies' => '192.168.1.1, 192.168.1.2', + + /* + * Or, to trust all proxies that connect + * directly to your server, use a "*" + */ + 'proxies' => env('TRUSTED_PROXIES', '*'), + + /* + * Which headers to use to detect proxy related data (For, Host, Proto, Port) + * + * Options include: + * + * - Illuminate\Http\Request::HEADER_X_FORWARDED_ALL (use all x-forwarded-* headers to establish trust) + * - Illuminate\Http\Request::HEADER_FORWARDED (use the FORWARDED header to establish trust) + * - Illuminate\Http\Request::HEADER_X_FORWARDED_AWS_ELB (If you are using AWS Elastic Load Balancer) + * + * - 'HEADER_X_FORWARDED_ALL' (use all x-forwarded-* headers to establish trust) + * - 'HEADER_FORWARDED' (use the FORWARDED header to establish trust) + * - 'HEADER_X_FORWARDED_AWS_ELB' (If you are using AWS Elastic Load Balancer) + * + * @link https://symfony.com/doc/current/deployment/proxies.html + */ + 'headers' => Illuminate\Http\Request::HEADER_X_FORWARDED_ALL, + +];