trustedproxy.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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' => [
  26. '192.168.1.10',
  27. ],
  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. * You may optionally set headers to 'null' here if you'd like
  51. * for them to be considered untrusted instead. Ex:
  52. *
  53. * Illuminate\Http\Request::HEADER_CLIENT_HOST => null,
  54. *
  55. * WARNING: If you're using AWS Elastic Load Balancing or Heroku,
  56. * the FORWARDED and X_FORWARDED_HOST headers should be set to null
  57. * as they are currently unsupported there.
  58. */
  59. 'headers' => [
  60. (defined('Illuminate\Http\Request::HEADER_FORWARDED') ? Illuminate\Http\Request::HEADER_FORWARDED : 'forwarded') => 'FORWARDED',
  61. Illuminate\Http\Request::HEADER_CLIENT_IP => 'X_FORWARDED_FOR',
  62. Illuminate\Http\Request::HEADER_CLIENT_HOST => 'X_FORWARDED_HOST',
  63. Illuminate\Http\Request::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO',
  64. Illuminate\Http\Request::HEADER_CLIENT_PORT => 'X_FORWARDED_PORT',
  65. ]
  66. ];