Mocking Required Environment Variables
ngshare
gets some configurations from the hub via environment variables. To run ngshare
, you will need to mock these variables. You should at least set the following:
JUPYTERHUB_API_TOKEN
should be a unique, secret token (such as one generated using openssl rand -hex 32
). This should be the same token specified in JupyterHub’s config.
JUPYTERHUB_API_URL
should point to the hub API, such as http://127.0.0.1:8080/hub/api
. Make sure this endpoint is accessible to ngshare
.
JUPYTERHUB_SERVICE_PREFIX
is the prefix under which ngshare
operates, with a leading and trailing slash. JupyterHub will proxy requests from /services/your-service-name/
, so this is usually /services/ngshare/
if the service name is ngshare
.
JUPYTERHUB_SERVICE_URL
is the URL that ngshare
should be accessible on. For example, if ngshare
has IP 10.1.2.3
and you want ngshare
to listen on port 1234, this should be http://10.1.2.3:1234
. Changing this will affect ngshare
’s port.
Configuring JupyterHub
Inside JupyterHub’s configuration Python script, add the following:
c.JupyterHub.services.append(
{
'name': 'ngshare',
'url': 'http://ngshare-location:1234',
'api_token': 'top-secret-api-token',
}
)
Make sure the url
field points to ngshare, and the api_token
is the same one specified as an environment variable to ngshare
.
After you restart JupyterHub, you can verify the service is working as intended by logging into JupyterHub, clicking “Control Panel”, then “Services -> ngshare”. If you see the ngshare
welcome page, you may proceed.