Neil Williams: LetsEncrypt with Apache, Gunicorn and Debian Bullseye
This took me far too long to identify and debug, so I'm going to write
it up here for my own reference and to possibly help others.
Background
Upgrading an old codebase from Python2 on Buster to Python3 ready for
Bullseye and from Django1 to Django2 (prepared for Django3). Everything
is fine at this stage - the Django test server is happy with HTTP and
it gives enough support to do the actual code changes to get to
Python3. All well and good so far. The main purpose of this particular
code was to support payments, so a chunk of the testing cannot be done
without HTTPS, which is where things got awkward.
This particular service needs HTTPS using LetsEncrypt and Apache2. To support
Django, I typically use Gunicorn.
All of this works with HTTP. Moving to HTTPS was easy to test using the
default-ssl virtual host that comes with Apache2 in Debian. It's a
static page and it worked well with https. The problems all start when
trying to use this known-working HTTPS config with the other Apache
virtual host to add support for the gunicorn proxy.
Apache reverse proxy AH00898 Error during SSL Handshake with remote server
Investigating
Now that I know why this happened, it's easier to see what was
happening. At the time, I was swamped in a plethora of options and
permutations between the Django HTTPS options and the Apache
VirtualHost SSL and proxy commands. Going through all of those took up
huge amounts of time, all in the wrong area.
In previous configurations using packages in Buster, gunicorn could
simply run on http://localhost:8000 and Apache would proxy that as
https.
In versions in Bullseye, this no longer works and it is that handover
from https in Apache to http in the proxy is where it is failing.
Apache is using HTTPS because the LetsEncrypt certificates, created
using dehydrated, are specified in the VirtualHost configuration. To
fix the handshake error, the proxy server needs to know about the
certificates created by dehydrated as well.
Gunicorn needs the certificates
The clue is in the gunicorn help:
The final part of the puzzle is that the certificates created by
dehydrated are in a private location:
To test gunicorn, this will mean using sudo but that's just a step
towards running gunicorn as a systemd service (when access to the certs
will not be a problem).
Starting gunicorn using these options shows the proxy now being
available at https://localhost:8000 which is a subtle but very
important change.
The specified locations are symbolic links created by dehydrated to
cope with regular updates of the certificates using cron.
--keyfile FILE SSL key file [None]
--certfile FILE SSL certificate file [None]
drwx------ 2 root root /var/lib/dehydrated/certs/
Environment=LOGLEVEL=DEBUG WORKERS=4 LOGFILE=/var/log/gunicorn/site.log
ExecStart=/usr/bin/gunicorn3 site.wsgi --log-level $LOGLEVEL --log-file $LOGFILE --workers $WORKERS \
--certfile /var/lib/dehydrated/certs/site/cert.pem \
--keyfile /var/lib/dehydrated/certs/site/privkey.pem
Perl REGEX Problems courtesy of XKCD
Grafana console showing the use of the label_replace function
Should online communities require people to create accounts before participating?
This question has been a source of disagreement among people who start or manage online communities for decades. Requiring accounts makes some sense since users contributing without accounts are a common source of vandalism, harassment, and low quality content. In theory, creating an account can deter these kinds of attacks while still making it pretty quick and easy for newcomers to join. Also, an account requirement seems unlikely to affect contributors who already have accounts and are typically the source of most valuable contributions. Creating accounts might even help community members build deeper relationships and commitments to the group in ways that lead them to stick around longer and contribute more.
I was recently called upon by Origyn to audit the source code of some of their








Last year I started collecting ideas of things I would like to 3D print
one day, on Twitter. Twitter is fundamentally ephemeral, so I'll collect
it here instead. I got up to 14 items on Twitter, and now I'm up to 25.
I don't own a 3D printer, but I have access to one at the work office.
Perhaps this list is my subconcious trying to convince me to buy one.
What am I missing? What else should I be thinking of printing? Let me
know!
An updated version 0.2.2 of the random-number generator tester
In October I was assigned 1.25 hours of work by Freexian's Debian LTS
initiative and carried over 28.75 hours from earlier months. I worked
14.75 hours and will carry over the remainder.
I updated the linux-4.19 package to merge in the changes in buster
release 10.11, uploaded that and issued