Skip to main content

This module implements a tiny HTTP proxy by extending BaseHTTPServer. Supports the GET, HEAD, POST, PUT, DELETE and CONNECT methods.

The latest version can be installed via PyPI:

$ pip install httproxy

or:

$ easy_install httproxy

The source code repository and issue tracker are maintained on GitHub.

Quickstart

Usage:

httproxy [options]
httproxy [options] <allowed-client> ...

Options:

-h, --help                   Show this screen.
--version                    Show version and exit.
-H, --host HOST              Host to bind to [default: 127.0.0.1].
-p, --port PORT              Port to bind to [default: 8000].
-l, --logfile PATH           Path to the logfile [default: STDOUT].
-i, --pidfile PIDFILE        Path to the pidfile [default: httproxy.pid].
-d, --daemon                 Daemonize (run in the background). The
                             default logfile path is httproxy.log in
                             this case.
-c, --configfile CONFIGFILE  Path to a configuration file.
-v, --verbose                Log headers.

To start the proxy server and bind it to port 22222 (the port on which it will listen and accept connections):

httproxy -p 22222

To start the proxy server, bind it to port 22222 and tell it to log all requests to the file httproxy.log:

httproxy -p 22222 -l httproxy.log

To start the proxy server so it only allows connections from IP 123.123.123.123:

httproxy 123.123.123.123

To start the proxy server bound to port 22222, log to file httproxy.log and run the server in the background (as a daemon):

httproxy -p 22222 -l httproxy.log -d

Configuration file

Every option stated as a command-line argument can be passed using a configuration file. httproxy looks for the following files to read configuration:

  • /etc/httproxy/config

  • $HOME/.httproxy/config (or %HOME%\.httproxy\config on Windows)

  • the value specified in --configfile on command-line

The names of the settings in the main section are derived from the long command line option names.

The allowed-clients section holds a list of hostnames that can access the proxy, one hostname per line. Remove this section or leave empty to allow any client to connect.

An example file:

[main]
host = localhost
port = 8011
logfile = /Users/ambv/.httproxy/log
pidfile = /Users/ambv/.httproxy/pid
daemon = yes
verbose = yes

[allowed-clients]
localhost
192.168.0.1

Note: command-line options have precedence over configuration file settings.

Optional dependencies

If you install setproctitle, the name of the process reported by ps will be more descriptive.

If you install psutil, httproxy will be able to automatically remove stale pidfiles on startup.

Change Log

0.9.0

  • ability to read configuration from a file (--configfile)

  • ability to specify the address the proxy will bind to (--host)

  • ability to log headers sent and received (--verbose)

  • better process management: pidfile support, a more descriptive process title (with the optional setproctitle dependency)

  • fixed spurious [Errno 54] Connection reset by peer tracebacks

  • properly shuts down when receiving SIGHUP, SIGINT or SIGTERM

  • major code refactoring

  • compatible with Python 2.6 and 2.7 only: requires docopt and configparser

0.3.1

  • added rudimentary FTP file retrieval

  • added custom logging methods

  • added code to make it run as a standalone application

Upgraded by Mitko Haralanov in 2009.

0.2.1

Authors

Script based on work by Suzuki Hisao and Mitko Haralanov, currently maintained by Łukasz Langa.

Metadata

Release files for httproxy 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for httproxy 0.9.0
File Size Uploaded Provenance
httproxy-0.9.0.tar.gz 9.1 kB Without provenance Details

Release files / httproxy-0.9.0.tar.gz

Download URL httproxy-0.9.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bf8381db311c8d2f1256ba16b77b1a9f9345a924e3fc50b436b59103082e66b9
BLAKE2b-256 checksum
How to use checksums
8e74790298ec094f08a42c85ce826b9db1cedb64ac382062c0c1fa6eb30c531f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for httproxy 0.9.0

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.

Release history Release notifications | RSS feed

This release

0.9.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page