HTTPS Support

I didn’t keep up with my promise to blog more regularly from summer 2016, but it’s a new year and I’m giving it another go.

To start things off, I decided to finally enable HTTPS for this site and my separate site for short fiction. Even though these sites are low-traffic and don’t deal with any sensitive information, it’s still a good idea to support HTTPS. See https://www.eff.org/encrypt-the-web for some background on why.

I had looked at doing this when I first started running this site,  but at the time it was a pretty tedious process. Today it’s straightforward, even though I’m on shared hosting.

First I needed to get certificates. I chose to use Let’s Encrypt, since it’s free, highly automated, and a joint, open effort. To actually interact with Let’s Encrypt, I installed the Acme PHP client on my web hosts. This tool allowed me to obtain the certificates via one shell command:

php bin/acme issue --domains andrewjamesjohnson.com:www.andrewjamesjohnson.com --path /home/andrewja/public_html:/home/andrewja/public_html --server letsencrypt

Then I modified the .htaccess file to redirect all HTTP traffic to HTTPS:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

And that’s it!

The only piece I don’t have totally working is automatic renewal of my certificates. I’ve got the renewal happening on a cron but it’s not yet updating the one used by the site.

env-var-import

env-var-import

Writing my last post on setting environment variables in GUI Emacs got me thinking about a more general solution to that problem. Rather than requiring everyone to define a function like set-exec-path-from-shell-PATH, it would be nice if there were a package that would handle importing everything for you given a list of environment variables.

To that end I wrote env-var-import. It’s available in Marmalade for easy installation: package-install env-var-import.

Once you’ve installed it, add (require 'env-var-import) to your Emacs configuration and you’re ready to do some importing!

You have two options for using it:

  1. (env-var-import): In this mode, it will only import the environment variable defined by env-var-import-exec-path-var and set exec-path to the value of that variable. env-var-import-exec-path-var defaults to to PATH but can be customized.
  2. (env-var-import '("VAR1" "VAR2")): In this mode it will still import the value of the environment variable defined in env-var-import-exec-path-var and set exec-path to that value. However, it will also import the values of VAR1 and VAR2.