Open RAbraham opened 4 years ago
This is my jupyterhub_config.py
. The one thing I'm not sure about in my config wrt the example_container_config is
c.JupyterHub.hub_ip = public_ips()[0]
I have
c.JupyterHub.hub_ip = 'jhub'
as I saw that somewhere in a perhaps a docker-compose
tutorial and my installation works like that but I'm not sure if that is the reason why it fails here?
import dockerspawner
from traitlets.config import get_config
import sys
import os
c = get_config()
os.environ['OAUTH2_TOKEN_URL']= f"{os.environ['HOST_URL']}/auth/realms/master/protocol/openid-connect/token"
from oauthenticator.generic import GenericOAuthenticator
c.JupyterHub.authenticator_class = GenericOAuthenticator
c.JupyterHub.authenticator_class.login_handler._OAUTH_AUTHORIZE_URL=f"{os.environ['HOST_URL']}/auth/realms/master/protocol/openid-connect/auth"
c.OAuthenticator.login_service = "15Rock"
c.OAuthenticator.client_id = os.environ['CLIENT_ID']
c.OAuthenticator.client_secret = os.environ['CLIENT_SECRET']
c.OAuthenticator.token_url = f"{os.environ['HOST_URL']}/auth/realms/master/protocol/openid-connect/token"
c.OAuthenticator.userdata_url = f"{os.environ['HOST_URL']}/auth/realms/master/protocol/openid-connect/userinfo"
c.OAuthenticator.userdata_method = 'GET'
c.OAuthenticator.userdata_params = {"state": "state"}
c.OAuthenticator.username_key = "preferred_username"
os.environ['OAUTH2_AUTHORIZE_URL']= f"{os.environ['HOST_URL']}/auth/realms/master/protocol/openid-connect/auth"
os.environ['OAUTH2_TOKEN_URL']= f"{os.environ['HOST_URL']}/auth/realms/master/protocol/openid-connect/token"
os.environ['OAUTH_CALLBACK_URL']= f"{os.environ['NOTEBOOK_URL']}/hub/oauth_callback"
os.environ['OAUTH2_USERDATA_URL']= f"{os.environ['HOST_URL']}/auth/realms/master/protocol/openid-connect/userinfo"
c.Spawner.args = [f"--NotebookApp.tornado_settings={{\"headers\":{{\"Content-Security-Policy\": \"frame-ancestors 'self' {os.environ['HOST_URL']}\"}}}}"]
c.JupyterHub.tornado_settings = {
'headers': {
'Content-Security-Policy': f"frame-ancestors 'self' {os.environ['HOST_URL']}"
}
}
#c.JupyterHub.authenticator_class = 'dummyauthenticator.DummyAuthenticator'
#c.DummyAuthenticator.password = "jam"
c.JupyterHub.cookie_secret = b'mysecret'
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
spawn_cmd = os.environ.get('DOCKER_SPAWN_CMD', "start-singleuser.sh")
c.DockerSpawner.extra_create_kwargs.update({ 'command': spawn_cmd })
c.DockerSpawner.debug = True
notebook_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan/work'
c.DockerSpawner.notebook_dir = notebook_dir
c.DockerSpawner.image = os.environ['DOCKER_JUPYTER_CONTAINER']
c.DockerSpawner.http_timeout=600
c.DockerSpawner.start_timeout=1200
# Mount the real user's Docker volume on the host to the notebook user's
# notebook directory in the container
c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir }
## Docker spawner
network_name = os.environ['DOCKER_NETWORK_NAME']
c.DockerSpawner.network_name = network_name
c.DockerSpawner.use_internal_ip = True
c.JupyterHub.hub_ip = 'jhub'
c.JupyterHub.services = [
{
'name': 'share-link',
'admin': True,
'url': 'http://127.0.0.1:21211',
'command': [sys.executable, '-m', 'jupyterhub_share_link.run'],
},
{
# the /services/<name> path for accessing the notebook viewer
'name': 'nbviewer',
# the interface and port nbviewer will use
'url': 'http://127.0.0.1:9000',
# the path to nbviewer repo
'cwd': '/srv/jupyterhub/nbviewer',
# command to start the nbviewer
'command': [sys.executable, '-m', 'nbviewer']
}
]
c.JupyterHub.admin_access = True # Service needs to access user servers.
c.JupyterHub.allow_named_servers = True
c.Spawner.cmd = ['jupyter-labhub']
c.DockerSpawner.remove_containers = True
c.DockerSpawner.image_whitelist = [
'localhost:5000/base-notebook-with-jupyterhub-share-labextension',
'danielballan/scipy-notebook-with-jupyterhub-share-labextension',
]
c.DockerSpawner.name_template = "{prefix}-{username}-{servername}"
c.Spawner.default_url = '/lab'
Hi, I'm testing this locally. I generated a url and when putting the url in the browser for another user, I get a 500 error. Inspecting the logs, I see
On a side note, as user2(the person who user1 gives the link too) , I have to login and spawn my notebook server before I can paste the url in the browser.