the-littlest-jupyterhub: Installing https support via Let's Encrypt appears broken (instructions problematic)
On a freshly installed jupyterhub that is visible to the outside world, I followed the Let’s Encrypt instructions on the Enabling HTTPS document page. I confirmed sudo -E tljh-config show
returns the expected content compared to what is in the documentation.
Problem 1) When I do sudo -E tljh-config reload proxy
, nothing happens. In fact, I realized that the connection hangs if you are doing this through the terminal on the jupyterhub. This is not surprising since it is shutting down http and turning on https. However, there is no warning in the documentation that this will happen.
Problem 2) When I try to go to the https connection, it is active, but the certificate is NOT being recognized as “verified by a third party.” (in Chrome, this is NET::ERR_CERT_AUTHORITY_INVALID) It does appear to be created since its name is “TRAEFIK DEFAULT CERT”.
The documentation should be updated to fix Problem 1, and I would appreciate any hints as to how to ‘redo’ the proxy connection properly. I did try re-running sudo -E tljh-config reload proxy
from ssh, and it returned Proxy reload with new configuration complete
but didn’t fix the issue.
We did revert to a snapshot of the VM from before activation of HTTPS and try the instructions from an SSH terminal. The result was the same except that sudo -E tljh-config reload proxy
from ssh, returned Proxy reload with new configuration complete
(since the http session terminal was not used), but the certificate is still not recognized as a third party verified certificate. Is there something more we need to do?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (3 by maintainers)
Ok, so to me the error is “clear” :
From: https://certbot.eff.org/docs/using.html#webroot
And tljh doesn’t allow to reach these files, thus, visibly, the challenge fails.
Thinking of it, I hadn’t set up the DNS redirection properly: I had set up a permanent web forwarding, not an A DNS (for foo.bar to ip) and CNAME DNS records (for www.foo.bar to foo.bar) Explanations here, and setup instructions if you’re on Gandi: https://docs.gandi.net/en/domain_names/common_operations/link_domain_to_website.html Other good Explanations : https://support.dnsimple.com/articles/a-record/
Now if I had done this properly from the start, it may have worked with the tljh’s default letsencrypt; When I find time, I’ll test 😉 (as I guess it works much better for the certificate renewal).
EDIT: This was indeed the problem, see my next post
Meanwhile, I finally got cerbot to work ( https://certbot.eff.org/lets-encrypt/ubuntubionic-other ) after quite a bit of trial-error, so I’m going to post what I’d been happy bumping on myself. However, it’s just what I did on my server, there may be shorter and simpler, but to be sure that would require a bit of testing that I don’t have time to do.
I was in root, all this will need extra sudo’s otherwise.
First, I undid all I had set up during my previous trials to setup https (we never know):
tljh-config unset https.enabled
tljh-config unset OR remove-item AnyOtherStuffTested
tljh-config reload
Then I tried the standalone certbot:
sudo certbot certonly --standalone --preferred-challenges http -d foo.bar -d www.foo.bar
But I had this error:Problem binding to port 80: Could not bind to IPv4 or IPv6.
So I started with:
ufw allow 80
But it didn’t work yetActually, the reason why it wasn’t working is that tljh still had it’s frontend running on my address.
So to see if I could stop it, I tried (note: my jupyter instances/servers where all already shutdown, no idea if it’s important):
systemctl | grep running
systemctl stop jupyterhub.service
Still not enough; by running:ss -tlnp | grep -E ":(80|443)"
I saw that I still had traefik squatting the ports; so:systemctl stop traefik.service
And yay! Finally
sudo certbot certonly --standalone --preferred-challenges http -d foo.bar -d www.foo.bar
worked 😃So
I finally could load my key and certificat following the instructions in the second part of the tutorial: http://tljh.jupyter.org/en/latest/howto/admin/https.html
Now the problem I guess, is that for certificat renewal, I’ll have to shut down the server again; so I’ll definitely try the proper way anew later.
Port 80 must be open for HTTP traffic over IPv4. I had mine restricted to IPv6 (by mistake) and allowing IPv4 traffic on 80 resolved it.
Sorry for my late answer, I’m quite busy at the moment; Here is precisely all I did, from a clean Ubuntu server 18.04 install:
If your user hasn’t the sudo rights:
From now on, everything is run from the normal user “yourusername”:
Now all is ready, we can do:
Then, get things going; I don’t know if it’s all needed:
At last, the normal SSL procedure from this page: http://tljh.jupyter.org/en/latest/howto/admin/https.html
When all is good:
sudo tljh-config reload proxy
Now if you configured the DNS records properly (see my previous long post), all should go fine, and going to “mydomain.me” should bring you directly on the login secured with https 😉
Good luck testing 😉
Note that i already had a working https setup on the same domain using the universal letsencrypt procedure {my long post above) but I then wiped everything at started with a new ubuntu install, so it should not affect anything. Second, all this was part of quite a bit of trial and error, so you’re welcome to suggest improvements!
(By the way, it seems that the only reliable way of installing extra python modules is to use the command
sudo -E pip intall module
in the jupyter notebook terminal online! ‒and doing asudo -E pip install --upgrade pip
before‒. I didn’t manage any install of working modules any other way ‒for example through ssh‒. When I have time I’ll dig this, as it’s another issue. Linked help page, that details the steps: http://tljh.jupyter.org/en/latest/howto/env/user-environment.html)Ok, so still fulfilling my noob role in this story, I ended up totally messing up my install. So I restarted from zero, and this time tested the proper tljh way of setting up a certificate. And guess what, it worked! So the issue was me not setting up the DNS records properly, confirmed.
By the way, having a look at
sudo systemctl status traefik.service
can help identify things a bit, if there is some network problem (I found it useful).