class ProxyMiddleware:
Proxy requests under a path to an external server, routing other requests to the app.
This middleware can only proxy HTTP requests, as HTTP is the only protocol handled by the WSGI server. Other protocols, such as WebSocket requests, cannot be proxied at this layer. This should only be used for development, in production a real proxy server should be used.
The middleware takes a dict mapping a path prefix to a dict describing the host to be proxied to:
app = ProxyMiddleware(app, { "/static/": { "target": "http://127.0.0.1:5001/", } })
Each host has the following options:
ssl.SSLContext
defining how to verify requests if the
target is HTTPS. The default is None.In the example above, everything under "/static/" is proxied to the server on port 5001. The host header is rewritten to the target, and the "/static/" prefix is removed from the URLs.
Parameters | |
app | The WSGI application to wrap. |
targets | Proxy target configurations. See description above. |
chunk_size | Size of chunks to read from input stream and write to target. |
timeout | Seconds before an operation to a target fails. |
Method | __call__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | proxy_to |
Undocumented |
Instance Variable | app |
Undocumented |
Instance Variable | chunk_size |
Undocumented |
Instance Variable | targets |
Undocumented |
Instance Variable | timeout |
Undocumented |
Undocumented
Parameters | |
environ:WSGIEnvironment | Undocumented |
start_response:StartResponse | Undocumented |
Returns | |
t.Iterable[ | Undocumented |
Undocumented
Parameters | |
app:WSGIApplication | Undocumented |
targets:t.Mapping[ | Undocumented |
chunk_size:int | Undocumented |
timeout:int | Undocumented |