Skip to main content

http-relay

Relay HTTP requests from localhost to a remote host (act as reverse HTTP proxy).

This HTTP relay properly processes also the nonstandard HTTP responses like ICY 200 OK produced by Shoutcast or NTRIP streaming servers.

The relay works properly with hostnames, IPv4 and IPv6 addresses. IPv6 addresses can be specified with or without [].

Usage

usage: http-relay [-h] [-n NUM_THREADS] [-b BUFFER_SIZE] [-t SIGKILL_TIMEOUT] [-s] host [port] [local_port] [local_addr]

positional arguments:
  host                  The remote host to connect to (e.g. "cvut.cz")
  port                  The remote host's port to connect to (e.g. 80).
  local_port            The local port to be used for the relay. If left out, will be the same as remote port.
  local_addr            Local interface (IP or hostname) to run the relay on. By default, it runs on all IPv4 interfaces (0.0.0.0).

optional arguments:
  -h, --help            show this help message and exit
  -n NUM_THREADS, --num-threads NUM_THREADS
                        Number of threads servicing the incoming requests.
  -b BUFFER_SIZE, --buffer-size BUFFER_SIZE
                        Size of the buffer used for reading responses. Generally, a larger buffer should be more efficient, but if it is too large, the local clients may time out before they receive any data.
  -t SIGKILL_TIMEOUT, --sigkill-timeout SIGKILL_TIMEOUT
                        If specified, the relay will be sigkilled in this number of seconds.
  -s, --sigkill-on-stream-stop
                        If True, --sigkill-timeout will not be counted when no requests are active, and during requests, each successful data transmission will reset the timeout. This can be used to detect
                        stale streams if you expect an application to be constantly receiving data.

Python module

This package also provides Python module http_relay. You can start the relay as a part of your application like this:

from http_relay import run

# ...

run("0.0.0.0", 80, "cvut.cz", 80)

Examples

http-relay cvut.cz 80 8080  # redirects local port 8080 to cvut.cz:80
http-relay cvut.cz 2101  # redirects local port 2101 to cvut.cz:2101
http-relay cvut.cz 80 8080 localhost  # redirects localhost:8080 to cvut.cz:80 (i.e. no external access to the 8080 port)

http-relay stream.cz 2101 -t 10 -s  # redirects local port 2101 to stream.cz and kills the relay after 10 secs if a stream is being downloaded and becomes stale

Release files for http-relay 2.1.3

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

Source distribution (sdist)

Source distribution for http-relay 2.1.3
File Size Uploaded
http-relay-2.1.3.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for http-relay 2.1.3
File Interpreter ABI Platform
http_relay-2.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / http-relay-2.1.3.tar.gz

Download URL http-relay-2.1.3.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
15f5d218cfa6d7187e47f0aefce725bd7445d1c5bcb9f285435eda3ec9fb9ddc
BLAKE2b-256 checksum
How to use checksums
54fea1d216fc990e3405c4630e95b347c5aa9e06638eae148ad93c44e4239916
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / http_relay-2.1.3-py3-none-any.whl

Download URL http_relay-2.1.3-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e476e3867cbf38165290113e69387c0330dd3687ed5c54688ae78aea73f4914e
BLAKE2b-256 checksum
How to use checksums
b38a877670a15589868663cfb570e9a2da2e8455ee9a9817e37e52459022f421
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

2.1.3 This release

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

1 release file

2.0.2

2 release files

2.0.1

2 release files

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