python-proxy-provider
A Traefik-like provider framework for dynamic proxy configuration in Python.
This project is not a full reverse proxy by itself. It is a provider engine that watches multiple sources (files, HTTP APIs, Docker, Consul, etc.) and produces a normalized routing configuration.
Use cases
- Build a Python Traefik-like router
- Build an edge gateway that reloads routes dynamically
- Implement Kubernetes/Docker providers in Python
- Provide unified routing config for multiple systems
Features
- Provider plugin interface (
ProviderBase) withstart()/stop()/current_config() - Provider manager — loads providers, merges configs, tracks background tasks
- File provider — watches YAML files for live changes via
watchfiles - HTTP provider — polls JSON routes from a remote endpoint with connection pooling
- Event bus — async pub/sub for config update notifications
- Graceful shutdown — signal handlers (SIGINT/SIGTERM) stop all providers cleanly
- Configurable logging —
--log-levelCLI option (DEBUG, INFO, WARNING, ERROR) - Merge conflict detection — logs warnings when multiple providers define the same router or service
Quickstart
Install
pip install python-proxy-provider
Run demo
proxy-provider run --file examples/routes.yml
Then edit examples/routes.yml and see live reload output.
Combine multiple providers:
proxy-provider run --file examples/routes.yml --http http://localhost:8000/routes --log-level DEBUG
Architecture
┌─────────────────┐
│ EventBus │
│ (async Queue) │
└──────┬──────────┘
┌────────────────┼────────────────┐
▼ ▼ ▼
FileProvider HttpProvider (future providers)
(watch YAML) (poll JSON) Docker, Consul, K8s
│ │ │
└────────────────┼────────────────┘
▼
ProviderManager
┌──────────┐
│ merge() │
└────┬─────┘
▼
DynamicConfig
(routers + services)
Provider API
Implement a custom provider by subclassing ProviderBase:
from python_proxy_provider.providers.base import ProviderBase
from python_proxy_provider.models import DynamicConfig
from python_proxy_provider.events import ConfigEvent
class MyProvider(ProviderBase):
name = "my"
async def start(self):
cfg = DynamicConfig(...)
await self.bus.publish(ConfigEvent(provider=self.name, config=cfg))
async def current_config(self) -> DynamicConfig:
return self._config
Roadmap
- Docker provider (watch containers)
- Consul provider
- Kubernetes provider
- Plugin discovery via
entry_points - Conflict resolution policies
- Distributed config cache
Changelog
0.1.1
- Graceful shutdown: Signal handlers (SIGINT/SIGTERM) stop all providers cleanly.
- Connection pooling: Shared
httpx.AsyncClientsingleton (was creating a client per request). - Logging: Replaced
print()with structuredloggingthroughout; added--log-levelCLI option. - Merge conflict detection: Warns when multiple providers define the same router/service key.
- EventBus close:
EventBus.close()prevents publishing after shutdown; subscribe loop exits cleanly. - Task tracking:
ProviderBasetracks background task for proper cancellation viastop(). - Bare except fixes: All
except Exceptionblocks re-raiseasyncio.CancelledError. - Build system: Migrated from
setuptoolstohatchling. Added classifiers, keywords, optional dev/test deps, ruff/pytest config. - Tests: Expanded from 1 test to 20 tests covering models, events, manager, file provider, and HTTP provider.
0.1.0
- Initial release: Provider plugin interface, file provider, HTTP provider, event bus, CLI demo.
License
MIT
Metadata
Release files for python-proxy-provider 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_proxy_provider-0.1.1.tar.gz | 10.3 kB | Without provenance | Details for python_proxy_provider-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_proxy_provider-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for python_proxy_provider-0.1.1-py3-none-any.whl |
Total release size: 20.5 kB
Release files / python_proxy_provider-0.1.1.tar.gz
| Download URL | python_proxy_provider-0.1.1.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
567eb08f8eee48502069e771b534d8419c5f2afe034cf590260cc82f1fd8bd11
|
|
BLAKE2b-256 checksum How to use checksums |
c540ac99dbedf21a444fbb09518dac540ccea5cafeccc32f950296a15a5048ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / python_proxy_provider-0.1.1-py3-none-any.whl
| Download URL | python_proxy_provider-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80feb92e70e47ca3d2cc3f4fc0e8d365819a937af21ea7858c3bf19a211b956e
|
|
BLAKE2b-256 checksum How to use checksums |
4e505a83959438a5535500b9364ddf7d489bef719c417163bc3cf10032b0bb9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for python-proxy-provider 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.