trustedproxy.php 1.7 KB

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