Launch Jupyter Hub in Q Blocks Instance

Setup Time: 5 minutes

Q Blocks instances offer Jupyter Lab access out of the box. It is great for quickly spawning up multiple notebooks, python console and terminal access within your browser. It also offers support for extensions that add superpowers to your notebooks.

However, there is another offering from the Jupyter community called as Jupyter Hub.

Unlike Notebooks or Lab, Jupyter Hub lets you have multiple user access.

If you are looking for extending access within your team to multiple users so they can have their isolated environments for running and managing notebooks then Hub is the best solution for you.

So, let’s get started!

Follow the 2 step process:

1. Install Jupyter Hub:

  • Run this command as qblocks user:

wget 'https://www.qblocks.cloud/resources/setup-jupyterhub.sh' --no-check-certificate -O - | bash

This script will install required dependencies and Jupyter hub software.

2. Launch Jupyter Hub:

  • See this guide on where to find Extra Port and Host information.

  • Run this command as qblocks user:

sudo jupyterhub --ip 0.0.0.0 --port EXTRA_PORT

EXTRA_PORT is the extra port shown under More info section of your instance.

Jupyter Hub Access:

Jupyter hub can be accessed at this URL:

http://HOST:EXTRA_PORT

Replace Host and Extra port with the values shown in More info section of your instance. See above mentioned guide to find Extra port and Host information.

Jupyter Hub URL can be shared across your team and each user account in your instance can access Jupyter Hub with their respective credentials.

See this section on How to create a new user account in Q Blocks instance.

Advanced Settings (Optional):

You may read further if you want to add an SSL certificate to access Jupyter Hub over HTTPS.

Jupyter Hub accepts a python configuration file in which you can specify all the necessary conditions like port mapping and security certificates.

Steps to follow:

  1. Generate or use an existing SSL certificate.

    • Store the certificate files in /home/qblocks/ as ssl.key and ssl.crt.

    • If you don’t have an SSL certificate, it can be generated using OpenSSL (example).

Please Note:

A self signed OpenSSL certificate may not be secure enough and we would recommend you to follow the industry standard practices to access your web services securely.

  1. Create a Jupyter Hub configuration file

  • Store this config file as /home/qblocks/jupyterhub_config.py:

Make sure to replace EXTRA_PORT with your instance’s extra port

# jupyterhub_config.py file
c = get_config()

import os
pjoin = os.path.join

# Allows multiple single-server per user
c.JupyterHub.allow_named_servers = True

c.JupyterHub.bind_url = 'http://0.0.0.0:EXTRA_PORT'

# https certificate setup
c.JupyterHub.ssl_key = '/home/qblocks/ssl.key'
c.JupyterHub.ssl_cert = '/home/qblocks/ssl.crt'

More info on Jupyter Hub config available here.

  1. Launch Jupyter Hub with configuration file:

sudo jupyterhub --config=/home/qblocks/jupyterhub_config.py

Visit https://HOST:EXTRA_PORT to access Jupyter Hub over https

If you still face issues setting it up then don't hesitate to reach out to us at: support@qblocks.cloud

Last updated