Skip to main content

PyProxy

CI codecov PyPI version Python 3.13+ License: MIT

A modern, production-grade reverse proxy built entirely in Python on asyncio.

PyProxy is a high-performance reverse proxy and load balancer designed for modern infrastructure. It implements its own HTTP request lifecycle from the ground up — no frameworks, no shortcuts.

Features

  • Async-native — Built on Python's asyncio with optional uvloop acceleration
  • Full HTTP/1.1 — Streaming, chunked encoding, keep-alive, persistent connections
  • Load Balancing — Round Robin, Weighted RR, Least Connections, IP Hash, and more
  • Health Checking — Active and passive checks with automatic recovery and circuit breaker
  • TLS Termination — Certificate loading, SNI, mutual TLS, OCSP stapling
  • WebSocket Proxy — Full upgrade, ping/pong, streaming, reconnect
  • Middleware Pipeline — Extensible before/after request hooks
  • Caching — In-memory and Redis with Cache-Control, ETag, conditional requests
  • Compression — gzip and Brotli with content negotiation
  • Authentication — JWT, Basic Auth, API Keys, OAuth hooks
  • Security — Rate limiting, IP allow/deny lists, CORS, CSRF, header sanitization
  • Observability — Prometheus metrics, structured JSON logging, request tracing
  • Hot Reload — Configuration changes applied without restart
  • CLIpyproxy start, validate, reload, benchmark, and more

Quick Start

Installation

pip install python-pyproxy

Configuration

Create a config.yaml:

server:
  bind_host: "0.0.0.0"
  bind_port: 8080

routes:
  - path: "/api"
    upstream:
      targets:
        - host: "127.0.0.1"
          port: 3000

logging:
  level: "info"
  format: "json"

Start the Proxy

pyproxy start config.yaml

Programmatic Usage

from pyproxy import Proxy

proxy = Proxy(config_path="config.yaml")
proxy.run()

Configuration

PyProxy supports YAML, JSON, and TOML configuration files. Environment variables can override any setting using the PYPROXY_ prefix:

# Override bind port
export PYPROXY_SERVER__BIND_PORT=9090

# Override log level
export PYPROXY_LOGGING__LEVEL=debug

See examples/ for annotated configuration examples.

Development

# Clone and install
git clone https://github.com/ashvn24/PyProxy.git
cd PyProxy
pip install -e ".[dev,test]"

# Run checks
make lint        # Ruff linting
make typecheck   # Mypy strict mode
make test        # Pytest
make coverage    # Coverage report
make check-all   # All of the above

See CONTRIBUTING.md for the full developer guide.

Architecture

PyProxy follows Clean Architecture with clear module boundaries:

Module Responsibility
server Low-level asyncio TCP server, connection lifecycle
routing Route matching (prefix, regex, host, wildcard)
proxy Reverse proxy engine, header rewriting, streaming
upstream Upstream connection pooling and management
load_balancer Load balancing strategies
health Health checking and circuit breaker
middleware Extensible middleware pipeline
config Configuration loading, validation, hot reload
ssl TLS termination, certificate management
websocket WebSocket proxy with upgrade handling
cache Response caching (memory, Redis)
compression gzip/Brotli response compression
auth Authentication (JWT, Basic, API Key)
security Rate limiting, CORS, IP filtering
metrics Prometheus metrics collection
logging Structured JSON logging with context

License

MIT — see LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_pyproxy-0.1.2.tar.gz (81.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_pyproxy-0.1.2-py3-none-any.whl (92.0 kB view details)

Uploaded Python 3

File details

Details for the file python_pyproxy-0.1.2.tar.gz.

File metadata

  • Download URL: python_pyproxy-0.1.2.tar.gz
  • Upload date:
  • Size: 81.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.7

File hashes

Hashes for python_pyproxy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0c3069e27c6b5162aa1f4957869bfba579f510317c6432b508916700fc1de1b0
MD5 eee456f76f903d3e787e9672f0f874ae
BLAKE2b-256 0d1ecb9c17a5393cca04eacd5ea431dedb93eff7e0508ed8841f03c7b80e9105

See more details on using hashes here.

File details

Details for the file python_pyproxy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: python_pyproxy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 92.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.7

File hashes

Hashes for python_pyproxy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 15fa2368781516ef0d1f51d6e0e007e0c6f9ce7f336e06e025957320afe53819
MD5 7dbc03c2853f53076e8c7beed05931e7
BLAKE2b-256 dcdba5335ba31c99a39f443158ccf275f3c1e988b5c53407933bb307cc6f70d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page