Set the correct REMOTE_ADDR based on the X-Forwarded-For header, while only trusting the CloudFront IP addresses.
This module is applied as WSGI middleware, fixing the IP-address retrieval for the entire application in a secure manner. As extra benefit, external packages no longer have to write abstraction layers to retrieve the IP-address header.
Django example
In Django edit the wsgi.py file to apply the module:
from django.core.wsgi import get_wsgi_application
from wsgi_aws_unproxy import UnProxy
application = get_wsgi_application()
application = UnProxy(application)
Now all packages can just read request.META['REMOTE_ADDR'] to fetch the correct IP. This includes contact forms, Sentry error reporting and rate limiting tools.
Installation
You can install the latest version using pip:
pip install wsgi-aws-unproxy
And apply it as WSGI middleware:
from wsgi_aws_unproxy import UnProxy
application = UnProxy(application)
Release files for wsgi-aws-unproxy 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wsgi-aws-unproxy-1.2.1.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wsgi_aws_unproxy-1.2.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / wsgi-aws-unproxy-1.2.1.tar.gz
| Download URL | wsgi-aws-unproxy-1.2.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e40a22f53af13f6e09bcc10ecc6c23ccbf26c26be6974b536568e06ac24121d
|
|
BLAKE2b-256 checksum How to use checksums |
f450c896a92f2ee00cfd9bc8c8482df60874afab38020410e2e4e57dfa39b20a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.7
|
Release files / wsgi_aws_unproxy-1.2.1-py2.py3-none-any.whl
| Download URL | wsgi_aws_unproxy-1.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
4b883036f7b5bf5b245ce347eee4e4e1bfc08c80f2f2168c38dffb3c52199a7d
|
|
BLAKE2b-256 checksum How to use checksums |
a3304c0793a32bad84014a5a28fe47ab1a82eb4d524e93029278b62769d6bab4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.7
|