async-proxy-headers
Small, dependency-free ASGI middleware for applying X-Forwarded-For and
X-Forwarded-Proto only when the connecting proxy is trusted.
This package extracts Uvicorn's mature ProxyHeadersMiddleware so applications
can use it without depending on an ASGI server implementation. The code and
tests are derived from Uvicorn, maintained
by Encode OSS Ltd and contributors. See
UPSTREAM.md
for exact provenance and changes.
Install
uv add async-proxy-headers
Use
from async_proxy_headers import ProxyHeadersMiddleware
app = ProxyHeadersMiddleware(app, trusted_hosts="127.0.0.1")
trusted_hosts accepts an IP address, IP network, literal host, comma-separated
string, or list of those values. "*" trusts every connecting peer.
Development
The uvicorn/ Git submodule records the exact upstream checkout used for the
extraction. It is not included in built distributions.
git submodule update --init
uv sync
uv run pytest
uv run pytest -m e2e
uv run ruff check src tests
uv run mypy
uv build
uv run twine check dist/*
The E2E suite launches Uvicorn, Gunicorn's native ASGI worker, and Granian, sends a real HTTP request through each, and verifies the middleware-adjusted client address and scheme returned by the application.
Releases publish through PyPI Trusted Publishing. Before the first release,
create the async-proxy-headers PyPI project (or use PyPI's pending publisher)
for GitHub owner kosovojs, repository async-proxy-headers, workflow
publish.yml, environment pypi.
License and credit
BSD-3-Clause, matching Uvicorn. Uvicorn's copyright notice, license conditions, and disclaimer are retained in LICENSE.md. This project is not endorsed by or affiliated with Encode OSS Ltd or the Uvicorn maintainers.
Metadata
Release files for async-proxy-headers 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| async_proxy_headers-0.1.0.tar.gz | 113.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_proxy_headers-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 119.7 kB
Release files / async_proxy_headers-0.1.0.tar.gz
| Download URL | async_proxy_headers-0.1.0.tar.gz |
|---|---|
| Size | 113.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe7fa317babf3b3290b91ecdb8503e24ecb8ab990189f0a1185663d8f55c9be0
|
|
BLAKE2b-256 checksum How to use checksums |
42cc0295e8a04bb014212d9039357971a499b3ca22d89eb4f35aaa10d37be570
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / async_proxy_headers-0.1.0-py3-none-any.whl
| Download URL | async_proxy_headers-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96a8ceddc786d1586401e8ae36c21c6321ae3b5dbc97fa2a7e475f0b97d1159a
|
|
BLAKE2b-256 checksum How to use checksums |
e860ae8a65a18c15ed8451997358a4e57187142566d03942e9d6928e1637ebce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|