Lightweight HTTP reverse proxy built on eventlet
Project description
proxylet: lightweight HTTP reverse proxy built on eventlet
This module implements a lightweight reverse proxy for HTTP, using non-blocking
IO based on the eventlet module. It aims to do as little as possible while
supporting simple request/response rewriting and being compatible with HTTP
keep-alive.
Basic operation is via the 'serve' function, which will bind to the
specified host and port and start accepting incoming HTTP requests:
proxylet.serve(host,port,mapper)
Here 'mapper' is a function taking a proxylet.streams.HTTPRequest object,
and returning either None (for '404 Not Found') or a 3-tuple giving the
destination host, destination port, and a rewriter object.
The rewriter can be any callable that takes request and response streams
as arguments and returns wrapped versions of them, but it will most likely
be a subclass of proxylet.relocate.Relocator. This class has the necessary
logic to rewrite the request for proxying.
As an example of the available functionality, this mapping function will
proxy requests to /svn to a private subversion server, requests to /files
to a private fileserver, and return 404 for any other paths:
def mapper(req):
svn = SVNRelocator("http://www.example.com/svn","http://svn.example.com/")
if svn.matchesLocal(req.reqURI):
return svn.mapping # contains the (host,port,rewriter) tuple
if req.reqURI.startswith("/files/"):
return ("files.example.com",80,None)
return None
This module implements a lightweight reverse proxy for HTTP, using non-blocking
IO based on the eventlet module. It aims to do as little as possible while
supporting simple request/response rewriting and being compatible with HTTP
keep-alive.
Basic operation is via the 'serve' function, which will bind to the
specified host and port and start accepting incoming HTTP requests:
proxylet.serve(host,port,mapper)
Here 'mapper' is a function taking a proxylet.streams.HTTPRequest object,
and returning either None (for '404 Not Found') or a 3-tuple giving the
destination host, destination port, and a rewriter object.
The rewriter can be any callable that takes request and response streams
as arguments and returns wrapped versions of them, but it will most likely
be a subclass of proxylet.relocate.Relocator. This class has the necessary
logic to rewrite the request for proxying.
As an example of the available functionality, this mapping function will
proxy requests to /svn to a private subversion server, requests to /files
to a private fileserver, and return 404 for any other paths:
def mapper(req):
svn = SVNRelocator("http://www.example.com/svn","http://svn.example.com/")
if svn.matchesLocal(req.reqURI):
return svn.mapping # contains the (host,port,rewriter) tuple
if req.reqURI.startswith("/files/"):
return ("files.example.com",80,None)
return None
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
proxylet-0.1.0.tar.gz
(11.5 kB
view details)
Built Distribution
proxylet-0.1.0-py2.5.egg
(23.0 kB
view details)
File details
Details for the file proxylet-0.1.0.tar.gz
.
File metadata
- Download URL: proxylet-0.1.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1e20ae86943d8b4dec81d19d53aa765d59a34ef8a77fbdf610dba933c9f7b82 |
|
MD5 | 3bad653d1f12db3703b6c588a8c0cd46 |
|
BLAKE2b-256 | fa220327673296048b164ea2f64bcd60132d4c0d0307c69954b2c78b0234ff17 |
File details
Details for the file proxylet-0.1.0-py2.5.egg
.
File metadata
- Download URL: proxylet-0.1.0-py2.5.egg
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad9fb4d6549b698af8b6cd257091d9bd22ebdf81ba2a489a961f0770001ffaac |
|
MD5 | 342e8f8b987361e60c255218db97b567 |
|
BLAKE2b-256 | f10c6fc76c26b7a79f6d30d7ca503ed9a9af446655e6ddc20932c1625c6e0d13 |