class werkzeug.middleware.http_proxy.ProxyMiddleware(app, targets, chunk_size=16384, timeout=10)
Proxy requests under a path to an external server, routing other requests to the app.
This middleware can only proxy HTTP requests, as that 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 proxying server should be used.
The middleware takes a dict that maps 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:
target:
remove_prefix:
False
.host:
"<auto>" (default):
None:
headers:
{}
.ssl_context:
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: |
|
---|
New in version 0.14.
© 2007–2020 Pallets
Licensed under the BSD 3-clause License.
https://werkzeug.palletsprojects.com/en/1.0.x/middleware/http_proxy/