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.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for wsgi-aws-unproxy-1.1.0.tar.gz
Algorithm Hash digest
SHA256 39088e3518ef7cb464e11ddeb99987a5ef55ebff5a30247722d22e4934e878d6
MD5 63a0796fc709b126a41b524f380ed2f5
BLAKE2b-256 289baf08a5bcfad3ee25426ef859b6508e68761da63469df42d7841d29820ef6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for wsgi_aws_unproxy-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c164960f71fc918e861389e443ab05c903cee8ec699b2dde35ce72324d287846
MD5 32769f1c340a9c47cf007d9032afdae3
BLAKE2b-256 da0f85498997d6d646c6144b3f9dc94e405fdf5196c89123f1c2aaaf7e531354

See more details on using hashes here.

Provenance

Supported by

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