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

Uploaded Source

Built Distribution

wsgi_aws_unproxy-1.2.0-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: wsgi-aws-unproxy-1.2.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for wsgi-aws-unproxy-1.2.0.tar.gz
Algorithm Hash digest
SHA256 686fbf85578a89b78152400f9db308f1ffe5b8340991f688994647b8e412f7a1
MD5 a10045fef98f4eac85ae62c07de4b0ce
BLAKE2b-256 28e5e8816d7601801da53170a8c1998314f581e40d7659cb3aad88f7b5106273

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: wsgi_aws_unproxy-1.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for wsgi_aws_unproxy-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 309f4784b3cca60b11ec5d38c657e0765b70a5f1728a55aed8e0d388959a46d4
MD5 eabd44a6eedd9655dab5e1c6b8e83f29
BLAKE2b-256 8f27abf12c9b9aba3ef938cf4c06b632d738b97ced3388c4bfb3e08be03cf917

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