HTTP Proxy Server¶
The code for this example is located in the
An asynchronous multi-process HTTP proxy server. It works for both
https (tunneled) requests.
It is possible to add middleware to manipulate the original request headers. If the header middleware is an empty list, the proxy passes requests and responses unmodified. This is an implementation for a forward-proxy which can be used to retrieve any type of source from the Internet.
To run the server:
An header middleware is a callable which receives the wsgi environ and the list of request headers. By default the example uses:
Add x-forwarded-for header
To run with different headers middleware create a new script and do:
from proxyserver.manage import server if __name__ == '__main__': server(headers_middleware=[...]).start()
WSGI middleware for an asynchronous proxy server.
To perform processing on headers you can pass a list of
headers_middleware. An headers middleware is a callable which accepts two parameters, the wsgi environ dictionary and the headers container.