Setting up HTTPS on JupyterHub in Docker container

Hello,

I am trying to set up jupyterhub in a docker container on https.

I am currently working on an AWS EC2 instance which is running a docker container with JupyterHub on HTTP.

I had primarily updated the bind url in the jupyterhub_config.py file following the instructions mentioned here
https://jupyterhub.readthedocs.io/en/stable/getting-started/networking-basics.html

c.jupyterHub.bind_url = ‘http://“ec2-private-ip”:8000’

Since I am running the jupyterhub inside docker, I use the -p flag when running the docker container to map port 80 from ec2 to port 8000 in the docker container.

This works fine and I am able to get Jupyterhub running on the ec2 instance port 80.
I am able to access the jupyterhub login from a web browser without any issues.

Now I am trying to set it up on port 443.

I was provided with the SSL certificate and key in the ec2 instance for setting up the access via HTTPS.

I mounted the folder with the cert and key as a volume when creating the container.
And I changed the jupyterhub_config.py to include the ssl cert and key as specified in the instructions
https://jupyterhub.readthedocs.io/en/stable/getting-started/security-basics.html

c.JupyterHub.bind_url = ‘https://“ec2-private-ip”:8000’
c.JupyterHub.ssl_key = ‘/path/to/mounted/volume/server.key’
c.JupyterHub.ssl_cert = ‘/path/to/mounted/volume/certificate.cer’

I have also tried changing the bind url to the one below:
c.JupyterHub.bind_url = ‘https://“ec2-private-ip”:443’

Now when I run the container using docker run -p 443:443 or 8000, the docker container is created without any errors and I can see that the port 443 is listening on the server, but I am not able to access the jupyterhub interface on the web browser.

I am not sure if I need to be changing any additional parameters on the jupyterhub_config file.

I am using the configurableHTTPproxy, but I did not make any changes to their parameters within the jupyterhub_config.py file as they worked fine for HTTP access.
I also ensured that the cert and key files have only 400 permission.

This is the first time I am setting up JupyterHub and docker this way, it would be great if someone could help me figure out what I am missing as the current set up works for http but fails for https.

Thanks!

1 Like