Proxy.py is a lightweight, dependency-optional, and pluggable framework for building fast proxy servers, web servers, and pub/sub systems. It supports HTTP, HTTPS, TLS interception, DNS-over-HTTPS, and can function as a reverse or forward proxy. Currently at version 2.4.10, the library maintains an active release cadence with frequent updates and new features.
pip install proxy.pyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to programmatically start a basic HTTP forward proxy on `127.0.0.1:8899` using `proxy.py`. The `Proxy.main()` method is used with a list of arguments, mimicking command-line input. The `with` statement ensures proper resource management. The `time.sleep` loop keeps the main thread alive while the proxy runs in its own threads, allowing it to handle requests until a `KeyboardInterrupt` (Ctrl+C) is received.
If implementing custom SSL handling, migrate to `SSLContext.wrap_socket`. The library's internal components generally handle this automatically in recent versions.
Ensure `pip install proxy.py[tls]` is used. Verify `openssl` is installed and accessible. For production, manage certificates securely and consider the `--insecure-tls-interception` flag only for development/testing.
Familiarize yourself with the plugin API (e.g., `HttpProxyPlugin`, `WebServerPlugin`, `GroutPlugin`). Ensure plugins are listed correctly in the `--plugins` argument or passed programmatically when initializing `Proxy`.
Review the Grout documentation thoroughly. Ensure correct hostnames, ports, and (if applicable) authentication are configured. Be mindful of security implications when exposing local services to the internet.
Always install with the necessary extras, e.g., `pip install proxy.py[dashboard,tls]`, to ensure all desired features and their dependencies are available.