HTTP Proxy Header support for FastAPI
This Python package allows transparent use of FastAPI-based solutions behind
proxies which set X-Forwarded-... headers. Applications will construct URLs
based on those headers rather than the incoming Host header.
Use
Install fastapi-proxiedheadersmiddleware using pip:
pip install fastapi-proxiedheadersmiddleware
The module can then be used as fastapi_proxiedheadersmiddleware when creating
your FastAPI app:
from fastapi import FastAPI
from fastapi_proxiedheadersmiddleware import ProxiedHeadersMiddleware
app = FastAPI()
app.add_middleware(ProxiedHeadersMiddleware)
The middleware respects the various X-Forwarded-... headers and updates the
Host header to match.
Developer quickstart
This project contains a dockerized testing environment which wraps tox.
Tests can be run using the ./test.sh command:
# Run all PyTest tests and Flake8 checks
$ ./test.sh
# Run just PyTest
$ ./test.sh -e py3
# Run a single test file within PyTest
$ ./test.sh -e py3 -- tests/test_identifiers.py
# Run a single test file within PyTest with verbose logging
$ ./test.sh -e py3 -- tests/test_identifiers.py -vvv
Release files for fastapi-proxiedheadersmiddleware 0.9.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 | |
|---|---|---|---|
| fastapi-proxiedheadersmiddleware-0.9.0.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_proxiedheadersmiddleware-0.9.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.3 kB
Release files / fastapi-proxiedheadersmiddleware-0.9.0.tar.gz
| Download URL | fastapi-proxiedheadersmiddleware-0.9.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5672f68cef03181b92d24aa5894c903dd0ac630f6781cfb148dee1f18eca1e38
|
|
BLAKE2b-256 checksum How to use checksums |
c974c899454e283c9d47c9b3d37fa81f9b6adb8201d80a0e5b7ae5f342b01ac5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|
Release files / fastapi_proxiedheadersmiddleware-0.9.0-py3-none-any.whl
| Download URL | fastapi_proxiedheadersmiddleware-0.9.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31b02e1321fc5bdd51c9f2dc60ca36ae1c7637a2fbad496eb34eb17483c260ea
|
|
BLAKE2b-256 checksum How to use checksums |
9e254be86a78e172137362334e7171fa3bd5214b7c46a6772091111bc6968871
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|