trustedproxy.php 1.9 KB

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