Migration from http to https for hugo blog
This week I moved the blog from http to https. The reason - everything is moving to https and maybe it’s good for SEO. There were several steps.
Move from GitHub to VPS
GitHub does not support https for custom domains, BitBucket also. Seems it’s possible with GitLab, but looks to complex. So, finally, I decided to move to VPS, also because I already have one. To do this I:
- changed
Makefile
to deploy with rsync
publish:
rm -rf public
hugo
rsync -avz --delete public/ user@server:/path/to/blog
- added apache2 conf
<VirtualHost *:80>
ServerName blog.sneawo.com
DocumentRoot /path/to/blog
<Directory /path/to/blog/>
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ...
CustomLog ...
</VirtualHost>
-
restarted apache
service apache2 restart
-
removed
CNAME
record from DNS and addedA
record to point to the server -
after DNS was updated, removed GitHub repository
Move from http to https
The next task was to generate certificate and enable https. Here are the steps:
-
changed the baseurl and the menu links in the blog config to use http instead https
-
changed disqus embed code in the theme template
-
generated certificate
certbot-auto --apache -d blog.sneawo.com certonly
-
updated apache2 conf
<VirtualHost *:80>
ServerName blog.sneawo.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =blog.sneawo.com
RewriteRule ^ https://blog.sneawo.com%{REQUEST_URI} [L,QSA,R=permanent]
ErrorLog ...
CustomLog ...
</VirtualHost>
<VirtualHost *:443>
ServerName blog.sneawo.com
DocumentRoot /path/to/blog
<Directory /path/to/blog/>
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ...
CustomLog ...
SSLCertificateFile /etc/letsencrypt/live/blog.sneawo.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/blog.sneawo.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/blog.sneawo.com/chain.pem
</VirtualHost>
-
deployed updated version
make publish
-
restarted apache
service apache2 restart
-
migrated disqus links with
Redirect Crawler
in Migration Tools