diff --git a/CONFIGURE.md b/CONFIGURE.md index 3572bff81..5acee7e45 100644 --- a/CONFIGURE.md +++ b/CONFIGURE.md @@ -42,6 +42,7 @@ Table with all the variables, default value and explanation. Override the enviro | MAIL_ENCRYPTION | null | Mail encryption | | MAIL_FROM_NAME | Control Center | Mail from name | | MAIL_FROM_ADDRESS | noreply@yourvacc.com | Mail from address | +| TRUSTED_PROXIES | null | Comma-separated list of trusted proxy addresses or '*' for all | #### OAuth diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 2b61e63e7..0c2d7ba0b 100755 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -12,7 +12,15 @@ class TrustProxies extends Middleware * * @var array */ - protected $proxies; + public function proxies(): null|string|array + { + $trusted = config('app.proxies.trusted'); + if ($trusted != null && str_contains($trusted, ',')) { + return explode(',', $trusted); + } + + return $trusted; + } /** * The headers that should be used to detect proxies. diff --git a/config/app.php b/config/app.php index 43f5d79bd..8a9bb57a3 100755 --- a/config/app.php +++ b/config/app.php @@ -240,6 +240,19 @@ ], + /* + |-------------------------------------------------------------------------- + | Network & Requests + |-------------------------------------------------------------------------- + | Configure the list of proxies that you trust if you are running Control + | Center behind a proxy such as nginx, traefik or similarly. + | Separate allowed proxies with a comma (no space!). + | If you're running Control Center in a container, you may set it to '*'. + */ + 'proxies' => [ + 'trusted' => env('TRUSTED_PROXIES'), + ], + /* |-------------------------------------------------------------------------- | Class Aliases