https://github.com/labd/wsgi-aws-unproxy
Process X-Forwarded-For headers for AWS
https://github.com/labd/wsgi-aws-unproxy
aws django wsgi
Last synced: about 1 month ago
JSON representation
Process X-Forwarded-For headers for AWS
- Host: GitHub
- URL: https://github.com/labd/wsgi-aws-unproxy
- Owner: labd
- License: mit
- Created: 2017-05-18T12:57:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-03-30T12:07:31.000Z (over 5 years ago)
- Last Synced: 2025-03-28T22:51:11.351Z (6 months ago)
- Topics: aws, django, wsgi
- Language: Python
- Homepage:
- Size: 41 KB
- Stars: 3
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES
- License: LICENSE
Awesome Lists containing this project
README
.. start-no-pypi
.. image:: https://github.com/labd/wsgi-aws-unproxy/workflows/Python%20Tests/badge.svg
:target: https://github.com/labd/wsgi-aws-unproxy/actions
.. image:: http://codecov.io/github/LabD/wsgi-aws-unproxy/coverage.svg?branch=master
:target: http://codecov.io/github/LabD/wsgi-aws-unproxy?branch=master.. image:: https://img.shields.io/pypi/l/wsgi-aws-unproxy.svg
:target: https://pypi.python.org/pypi/wsgi-aws-unproxy/.. image:: https://img.shields.io/pypi/v/wsgi-aws-unproxy.svg
:target: https://pypi.python.org/pypi/wsgi-aws-unproxy/.. end-no-pypi
================
WSGI AWS Unproxy
================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:
.. code-block:: python
from django.core.wsgi import get_wsgi_application
from wsgi_aws_unproxy import UnProxyapplication = 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:
.. code-block:: bash
pip install wsgi-aws-unproxy
And apply it as WSGI middleware:
.. code-block:: python
from wsgi_aws_unproxy import UnProxy
application = UnProxy(application)