{"id":10056,"library":"pproxy","title":"pproxy - A Powerful Regex-Based Proxy Server","description":"pproxy is a Python proxy server that enables tunneling among remote servers using configurable regex rules. It supports various protocols like HTTP, SOCKS, and SSL. The current version is 2.7.9, with active development and releases typically occurring every few months to address bug fixes and new features.","status":"active","version":"2.7.9","language":"en","source_language":"en","source_url":"https://github.com/qwj/python-proxy","tags":["proxy","networking","server","tunneling","asyncio","regex"],"install":[{"cmd":"pip install pproxy","lang":"bash","label":"Install pproxy"}],"dependencies":[],"imports":[{"note":"The primary programmatic entry point for pproxy, typically used to run the server with simulated command-line arguments.","symbol":"main","correct":"from pproxy import main"}],"quickstart":{"code":"import sys\nfrom pproxy import main\n\n# Configure pproxy to listen on HTTP port 8080\n# and forward all requests to a SOCKS5 proxy at 127.0.0.1:1080.\n# This simulates running: python -m pproxy -l http://:8080 -r socks5://127.0.0.1:1080\n\nsys.argv = ['pproxy', '-l', 'http://:8080', '-r', 'socks5://127.0.0.1:1080']\nprint(\"Starting pproxy server on http://:8080, forwarding to socks5://127.0.0.1:1080...\")\nprint(\"Press Ctrl+C to stop.\")\n\ntry:\n    main()\nexcept KeyboardInterrupt:\n    print(\"\\npproxy server stopped.\")","lang":"python","description":"This quickstart demonstrates how to programmatically start a pproxy server using its `main` function. It configures the proxy to listen for HTTP connections on port 8080 and forward them to a remote SOCKS5 proxy running on localhost:1080. This mimics command-line invocation for embedded use."},"warnings":[{"fix":"Ensure your application's main loop or context is compatible with asyncio when embedding `pproxy.main()`. If you are running `main()` directly, it will handle the event loop.","message":"pproxy migrated to asyncio in version 2.0.0. While the command-line interface remains consistent, programmatic users integrating `pproxy.main()` into existing blocking codebases might encounter unexpected behavior or need to adapt their environment to run `asyncio` event loops.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Always include the protocol scheme (e.g., `http://`, `https://`, `socks5://`) when specifying listen and remote addresses. Consult the documentation for exact syntax.","message":"The `-l` (listen) and `-r` (remote) arguments require specific URL-like formats (e.g., `http://:8080`, `socks5://user:pass@host:port`). Omitting the scheme (e.g., just `:8080`) or providing an incorrect format is a common mistake that leads to parsing errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Familiarize yourself with Python's `re` module syntax when defining complex remote rules. Test your regex patterns thoroughly to ensure they match traffic as intended.","message":"The `-r` (remote) rules use full Python regular expressions to match incoming requests against defined patterns. Users often expect simple wildcard matching (e.g., `*`) and are surprised by the full regex syntax, leading to misconfigured routing.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Choose a different port for pproxy to listen on, or identify and terminate the process currently using the desired port.","cause":"The specified listening port (e.g., 8080) is already occupied by another process on your system.","error":"Address already in use"},{"fix":"Install the package using `pip install pproxy`. If using virtual environments, ensure you activate the correct one before running.","cause":"The `pproxy` package is not installed in the currently active Python environment, or the environment is not correctly configured.","error":"No module named 'pproxy'"},{"fix":"Ensure that all listen and remote addresses are prefixed with their respective protocol schemes, e.g., `http://:8080`, `socks5://127.0.0.1:1080`.","cause":"The argument provided for a listen (`-l`) or remote (`-r`) address does not conform to the expected URL-like format, often missing a protocol scheme.","error":"ValueError: Invalid URL format for listen address: ..."},{"fix":"Verify that the `pproxy` server is running and accessible on the specified port. Check firewall rules on both the proxy host and the remote host. Ensure the remote server is active and listening.","cause":"This typically occurs when a client tries to connect to the pproxy server but the server is not running, or when pproxy tries to connect to a remote server that is unreachable, blocked by a firewall, or not running.","error":"Connection refused"}]}