Proxy API

Module: jupyterhub_traefik_proxy

Traefik implementation of the JupyterHub proxy API

TraefikProxy

class jupyterhub_traefik_proxy.TraefikProxy(**kwargs)[source]

JupyterHub Proxy implementation using traefik

config c.TraefikProxy.check_route_timeout = Int(30)

Timeout (in seconds) when waiting for traefik to register an updated route.

config c.TraefikProxy.should_start = Bool(True)

Should the Hub start the proxy

If True, the Hub will start the proxy and stop it. Set to False if the proxy is managed externally, such as by systemd, docker, or another service manager.

config c.TraefikProxy.toml_static_config_file = Unicode('traefik.toml')

traefik’s static configuration file

config c.TraefikProxy.traefik_api_password = Unicode('')

The password for traefik api login

config c.TraefikProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')

traefik authenticated api endpoint url

config c.TraefikProxy.traefik_api_username = Unicode('')

The username for traefik api login

add_route(routespec, target, data)[source]

Add a route to the proxy.

Subclasses must define this method

Parameters:
  • routespec (str) – A URL prefix ([host]/path/) for which this route will be matched, e.g. host.name/path/
  • target (str) – A full URL that will be the target of this route.
  • data (dict) – A JSONable dict that will be associated with this route, and will be returned when retrieving information about this route.

Will raise an appropriate Exception (FIXME: find what?) if the route could not be added.

The proxy implementation should also have a way to associate the fact that a route came from JupyterHub.

config c.TraefikProxy.check_route_timeout = Int(30)

Timeout (in seconds) when waiting for traefik to register an updated route.

delete_route(routespec)[source]

Delete a route with a given routespec if it exists.

Subclasses must define this method

get_all_routes()[source]

Fetch and return all the routes associated by JupyterHub from the proxy.

Subclasses must define this method

Should return a dictionary of routes, where the keys are routespecs and each value is a dict of the form:

{
  'routespec': the route specification ([host]/path/)
  'target': the target host URL (proto://host) for this route
  'data': the attached data dict for this route (as specified in add_route)
}
get_route(routespec)[source]

Return the route info for a given routespec.

Parameters:routespec (str) – A URI that was used to add this route, e.g. host.tld/path/
Returns:dict with the following keys:
'routespec': The normalized route specification passed in to add_route
    ([host]/path/)
'target': The target host for this route (proto://host)
'data': The arbitrary data dict that was passed in by JupyterHub when adding this
        route.

None: if there are no routes matching the given routespec

Return type:result (dict)
start()[source]

Start the proxy.

Will be called during startup if should_start is True.

Subclasses must define this method if the proxy is to be started by the Hub

stop()[source]

Stop the proxy.

Will be called during teardown if should_start is True.

Subclasses must define this method if the proxy is to be started by the Hub

config c.TraefikProxy.toml_static_config_file = Unicode('traefik.toml')

traefik’s static configuration file

config c.TraefikProxy.traefik_api_password = Unicode('')

The password for traefik api login

config c.TraefikProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')

traefik authenticated api endpoint url

config c.TraefikProxy.traefik_api_username = Unicode('')

The username for traefik api login

TraefikEtcdProxy

class jupyterhub_traefik_proxy.TraefikEtcdProxy(**kwargs)[source]

JupyterHub Proxy implementation using traefik and etcd

config c.TraefikEtcdProxy.check_route_timeout = Int(30)

Timeout (in seconds) when waiting for traefik to register an updated route.

config c.TraefikEtcdProxy.etcd_jupyterhub_prefix = Unicode('/jupyterhub/')

The etcd key prefix for traefik dynamic configuration

config c.TraefikEtcdProxy.etcd_password = Unicode('')

The password for etcd login

config c.TraefikEtcdProxy.etcd_traefik_prefix = Unicode('/traefik/')

The etcd key prefix for traefik static configuration

config c.TraefikEtcdProxy.etcd_url = Unicode('http://127.0.0.1:2379')

The URL of the etcd server

config c.TraefikEtcdProxy.etcd_username = Unicode('')

The username for etcd login

config c.TraefikEtcdProxy.should_start = Bool(True)

Should the Hub start the proxy

If True, the Hub will start the proxy and stop it. Set to False if the proxy is managed externally, such as by systemd, docker, or another service manager.

config c.TraefikEtcdProxy.toml_static_config_file = Unicode('traefik.toml')

traefik’s static configuration file

config c.TraefikEtcdProxy.traefik_api_password = Unicode('')

The password for traefik api login

config c.TraefikEtcdProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')

traefik authenticated api endpoint url

config c.TraefikEtcdProxy.traefik_api_username = Unicode('')

The username for traefik api login

add_route(routespec, target, data)[source]

Add a route to the proxy.

Subclasses must define this method

Parameters:
  • routespec (str) – A URL prefix ([host]/path/) for which this route will be matched, e.g. host.name/path/
  • target (str) – A full URL that will be the target of this route.
  • data (dict) – A JSONable dict that will be associated with this route, and will be returned when retrieving information about this route.

Will raise an appropriate Exception (FIXME: find what?) if the route could not be added.

The proxy implementation should also have a way to associate the fact that a route came from JupyterHub.

delete_route(routespec)[source]

Delete a route with a given routespec if it exists.

Subclasses must define this method

config c.TraefikEtcdProxy.etcd_jupyterhub_prefix = Unicode('/jupyterhub/')

The etcd key prefix for traefik dynamic configuration

config c.TraefikEtcdProxy.etcd_password = Unicode('')

The password for etcd login

config c.TraefikEtcdProxy.etcd_traefik_prefix = Unicode('/traefik/')

The etcd key prefix for traefik static configuration

config c.TraefikEtcdProxy.etcd_url = Unicode('http://127.0.0.1:2379')

The URL of the etcd server

config c.TraefikEtcdProxy.etcd_username = Unicode('')

The username for etcd login

get_all_routes()[source]

Fetch and return all the routes associated by JupyterHub from the proxy.

Subclasses must define this method

Should return a dictionary of routes, where the keys are routespecs and each value is a dict of the form:

{
  'routespec': the route specification ([host]/path/)
  'target': the target host URL (proto://host) for this route
  'data': the attached data dict for this route (as specified in add_route)
}
get_route(routespec)[source]

Return the route info for a given routespec.

Parameters:routespec (str) – A URI that was used to add this route, e.g. host.tld/path/
Returns:dict with the following keys:
'routespec': The normalized route specification passed in to add_route
    ([host]/path/)
'target': The target host for this route (proto://host)
'data': The arbitrary data dict that was passed in by JupyterHub when adding this
        route.

None: if there are no routes matching the given routespec

Return type:result (dict)
start()[source]

Start the proxy.

Will be called during startup if should_start is True.

Subclasses must define this method if the proxy is to be started by the Hub

stop()[source]

Stop the proxy.

Will be called during teardown if should_start is True.

Subclasses must define this method if the proxy is to be started by the Hub

TraefikTomlProxy

class jupyterhub_traefik_proxy.TraefikTomlProxy(**kwargs)[source]

JupyterHub Proxy implementation using traefik and toml config file

config c.TraefikTomlProxy.check_route_timeout = Int(30)

Timeout (in seconds) when waiting for traefik to register an updated route.

config c.TraefikTomlProxy.should_start = Bool(True)

Should the Hub start the proxy

If True, the Hub will start the proxy and stop it. Set to False if the proxy is managed externally, such as by systemd, docker, or another service manager.

config c.TraefikTomlProxy.toml_dynamic_config_file = Unicode('rules.toml')

traefik’s dynamic configuration file

config c.TraefikTomlProxy.toml_static_config_file = Unicode('traefik.toml')

traefik’s static configuration file

config c.TraefikTomlProxy.traefik_api_password = Unicode('')

The password for traefik api login

config c.TraefikTomlProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')

traefik authenticated api endpoint url

config c.TraefikTomlProxy.traefik_api_username = Unicode('')

The username for traefik api login

add_route(routespec, target, data)[source]

Add a route to the proxy.

Subclasses must define this method

Parameters:
  • routespec (str) – A URL prefix ([host]/path/) for which this route will be matched, e.g. host.name/path/
  • target (str) – A full URL that will be the target of this route.
  • data (dict) – A JSONable dict that will be associated with this route, and will be returned when retrieving information about this route.

Will raise an appropriate Exception (FIXME: find what?) if the route could not be added.

The proxy implementation should also have a way to associate the fact that a route came from JupyterHub.

delete_route(routespec)[source]

Delete a route with a given routespec if it exists.

Subclasses must define this method

get_all_routes()[source]

Fetch and return all the routes associated by JupyterHub from the proxy.

Subclasses must define this method

Should return a dictionary of routes, where the keys are routespecs and each value is a dict of the form:

{
  'routespec': the route specification ([host]/path/)
  'target': the target host URL (proto://host) for this route
  'data': the attached data dict for this route (as specified in add_route)
}
get_route(routespec)[source]

Return the route info for a given routespec.

Parameters:routespec (str) – A URI that was used to add this route, e.g. host.tld/path/
Returns:dict with the following keys:
'routespec': The normalized route specification passed in to add_route
    ([host]/path/)
'target': The target host for this route (proto://host)
'data': The arbitrary data dict that was passed in by JupyterHub when adding this
        route.

None: if there are no routes matching the given routespec

Return type:result (dict)
start()[source]

Start the proxy.

Will be called during startup if should_start is True.

Subclasses must define this method if the proxy is to be started by the Hub

stop()[source]

Stop the proxy.

Will be called during teardown if should_start is True.

Subclasses must define this method if the proxy is to be started by the Hub

config c.TraefikTomlProxy.toml_dynamic_config_file = Unicode('rules.toml')

traefik’s dynamic configuration file