jupyterhub-deploy-docker
jupyterhub-deploy-docker copied to clipboard
Redirecting HTTP to HTTPS
I'm using jupyterhub 1.0 docker image. When changing configs to use SSL, https://mydomain.com is accessible, however, http://mydomain.com is not. I have seen that the problem can be addressed by setting up a reverse proxy (Nginx or something) to sit between Jupyterhub and browsers for redirecting requests to port 80 to 443 of Jupyterhub. Just wanted to know if the same result can be achieved without the reverse proxy. My question is similar to this.
Try this
diff --git a/docker-compose.yml b/docker-compose.yml
index ffb3069..0c7b8c9 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -36,6 +36,7 @@ services:
- "data:${DATA_VOLUME_CONTAINER}"
ports:
- "443:443"
+ - "80:80"
links:
- hub-db
environment:
diff --git a/jupyterhub_config.py b/jupyterhub_config.py
index c81161b..6f358e0 100644
--- a/jupyterhub_config.py
+++ b/jupyterhub_config.py
@@ -52,6 +52,9 @@ c.JupyterHub.port = 443
c.JupyterHub.ssl_key = os.environ['SSL_KEY']
c.JupyterHub.ssl_cert = os.environ['SSL_CERT']
+# Redirect HTTP requests on port 80 to the server on HTTPS
+c.ConfigurableHTTPProxy.command = ['configurable-http-proxy', '--redirect-port', '80']
+
# Authenticate users with GitHub OAuth
c.JupyterHub.authenticator_class = 'oauthenticator.GitHubOAuthenticator'
c.GitHubOAuthenticator.oauth_callback_url = os.environ['OAUTH_CALLBACK_URL']
Thank you very much. It solved the problem. :+1: