Skip to main content

Simple wsgi middleware to unproxy AWS

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsgi-aws-unproxy-1.0.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wsgi_aws_unproxy-1.0.0-py2.py3-none-any.whl (4.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file wsgi-aws-unproxy-1.0.0.tar.gz.

File metadata

File hashes

Hashes for wsgi-aws-unproxy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c54c74a9548b80d217467423dee5f4c40b5682467ba1d59ce523c4ec7de1fdc7
MD5 b67fb24463fe3f10bbb5f7f7d0ffc7fe
BLAKE2b-256 68a1af4618d8ebcb7b51091baf712c895109a66f3250460300358ee53fefc93f

See more details on using hashes here.

File details

Details for the file wsgi_aws_unproxy-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for wsgi_aws_unproxy-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cd98b7520fb516fa4c396e4acf84347225575cda9baf9b2b21b0dc6b1abd010d
MD5 7703f23b553704fd6d947bf6433cddc8
BLAKE2b-256 f63a0491f1602f9004c6400034c582d925f54693d7a2b1e40bcb3ef2d5f82148

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page