|
| 1 | +<?php |
| 2 | + |
| 3 | +return [ |
| 4 | + |
| 5 | + /* |
| 6 | + * Set trusted proxy IP addresses. |
| 7 | + * |
| 8 | + * Both IPv4 and IPv6 addresses are |
| 9 | + * supported, along with CIDR notation. |
| 10 | + * |
| 11 | + * The "*" character is syntactic sugar |
| 12 | + * within TrustedProxy to trust any proxy |
| 13 | + * that connects directly to your server, |
| 14 | + * a requirement when you cannot know the address |
| 15 | + * of your proxy (e.g. if using Rackspace balancers). |
| 16 | + * |
| 17 | + * The "**" character is syntactic sugar within |
| 18 | + * TrustedProxy to trust not just any proxy that |
| 19 | + * connects directly to your server, but also |
| 20 | + * proxies that connect to those proxies, and all |
| 21 | + * the way back until you reach the original source |
| 22 | + * IP. It will mean that $request->getClientIp() |
| 23 | + * always gets the originating client IP, no matter |
| 24 | + * how many proxies that client's request has |
| 25 | + * subsequently passed through. |
| 26 | + */ |
| 27 | + 'proxies' => in_array(env('TRUSTED_PROXIES', ['*', '**'])) ? |
| 28 | + env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES', null)), |
| 29 | + |
| 30 | + /* |
| 31 | + * Or, to trust all proxies that connect |
| 32 | + * directly to your server, uncomment this: |
| 33 | + */ |
| 34 | + // 'proxies' => '*', |
| 35 | + |
| 36 | + /* |
| 37 | + * Or, to trust ALL proxies, including those that |
| 38 | + * are in a chain of fowarding, uncomment this: |
| 39 | + */ |
| 40 | + // 'proxies' => '**', |
| 41 | + |
| 42 | + /* |
| 43 | + * Default Header Names |
| 44 | + * |
| 45 | + * Change these if the proxy does |
| 46 | + * not send the default header names. |
| 47 | + * |
| 48 | + * Note that headers such as X-Forwarded-For |
| 49 | + * are transformed to HTTP_X_FORWARDED_FOR format. |
| 50 | + * |
| 51 | + * The following are Symfony defaults, found in |
| 52 | + * \Symfony\Component\HttpFoundation\Request::$trustedHeaders |
| 53 | + */ |
| 54 | + 'headers' => [ |
| 55 | + \Illuminate\Http\Request::HEADER_CLIENT_IP => 'X_FORWARDED_FOR', |
| 56 | + \Illuminate\Http\Request::HEADER_CLIENT_HOST => 'X_FORWARDED_HOST', |
| 57 | + \Illuminate\Http\Request::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO', |
| 58 | + \Illuminate\Http\Request::HEADER_CLIENT_PORT => 'X_FORWARDED_PORT', |
| 59 | + ], |
| 60 | +]; |
0 commit comments