orangeqs.juice.dashboard._influxdb2_proxy#

Reverse proxy for the InfluxDB2 UI.

This proxy is responsible for:

  • Rewriting URLs and cookies in the response body to include the JupyterHub prefix. The InfluxDB2 UI does not support being served under a subpath.

  • Serving a /auto-login endpoint that automatically logs the user in. The InfluxDB2 UI does not support auto-login.

This proxy is built on top of the the proxy.py package. To run this proxy, use the following command. This command for the /influxdb2 proxy in the jupyter-server-proxy configuration.

proxy     --enable-reverse-proxy     --plugins orangeqs.juice.dashboard._influxdb2_proxy.InfluxReverseProxyPlugin     --port 8086

Module Contents#

Classes#

InfluxReverseProxyPlugin

Proxy plugin to handle prefixing for InfluxDB2 UI when served under a subpath.

Functions#

handle_upstream_data

Replace URLs in response body and cookies to include the Jupyterhub prefix.

Data#

API#

orangeqs.juice.dashboard._influxdb2_proxy.PREFIX#

‘encode(…)’

orangeqs.juice.dashboard._influxdb2_proxy.CONTENT_TYPES_TO_FILTER: tuple[str, ...]#

(‘text/css’, ‘text/javascript’, ‘application/javascript’, ‘application/json’, ‘text/html’)

orangeqs.juice.dashboard._influxdb2_proxy.UPSTREAM_HOST#

None

orangeqs.juice.dashboard._influxdb2_proxy.UPSTREAM_PORT#

None

class orangeqs.juice.dashboard._influxdb2_proxy.InfluxReverseProxyPlugin(uid: str, flags: argparse.Namespace, client: proxy.http.connection.HttpClientConnection, event_queue: proxy.core.event.EventQueue, upstream_conn_pool: Optional[proxy.core.connection.UpstreamConnectionPool] = None)#

Bases: proxy.http.server.ReverseProxyBasePlugin

Proxy plugin to handle prefixing for InfluxDB2 UI when served under a subpath.

Has the following responsibilities:

  • Serve /env.js

  • Serve /auto-login

  • Forward to upstream host/port from env vars

routes() list[str | tuple[str, list[bytes]]]#

List of routes registered by plugin.

There are 2 types of routes:

  1. Dynamic routes (str): Should be a regular expression

  2. Static routes (tuple): Contain 2 elements, a route regular expression and list of upstream urls to serve when the route matches.

Static routes doesn’t require you to implement the handle_route method. Reverse proxy core will automatically pick one of the configured upstream URL and serve it out-of-box.

Dynamic routes are helpful when you want to dynamically match and serve upstream urls. To handle dynamic routes, you must implement the handle_route method, which must return the url to serve.

before_routing(request: proxy.http.parser.HttpParser) proxy.http.parser.HttpParser | None#

Set the accept encoding header to none to avoid compression.

handle_route(request: proxy.http.parser.HttpParser, pattern: re.Pattern[Any]) memoryview | proxy.http.Url | proxy.core.connection.TcpServerConnection#

Implement this method if you have configured dynamic routes.

orangeqs.juice.dashboard._influxdb2_proxy.handle_upstream_data(self: proxy.http.server.reverse.ReverseProxy, raw: memoryview) None#

Replace URLs in response body and cookies to include the Jupyterhub prefix.