Fixes for hosting on HTTPS

What it says on the tin. See the commits for more details.