Login

Tag "x-forwarded-for"

Snippet List

Add get_addr() method to request object

I thought it would be useful to have a `get_addr()` method available on request objects, similar to the `get_host()` provided by Django. This middleware will add a `get_addr()` method to requests which uses the `X-Forwarded-For` header (useful if you're behind a proxy) if it's present and you have the `USE_X_FORWARDED_FOR` header set to `True` (default is `False`) and otherwise will use the `REMOTE_ADDR` environment variable. Note that if you are *not* behind a proxy and have `USE_X_FORWARDED_FOR` set to `True`, then clients can spoof their IP by simply setting the `X-Forwarded-For header`.

  • request
  • ip
  • header
  • address
  • client
  • remote-addr
  • x-forwarded-for
  • get-addr
Read More

1 snippet posted so far.