A long time ago I set up a WordPress blog for a family member. Though there are lots of other options these days, back then there were few decent choices if your requirement was a web-based CMS with a WYSIWYG editor. An unfortunate side effect of things working well was that quite a lot of content for that blog has been generated over time. That means I've also been in the business of regularly updating WordPress to protect against the exploits that are always popping up.

Recently I wanted to convince the family member that switching to Hugo would be relatively easy, and the blog could then be hosted on GitLab (just like this one!) Trying to extract all that content and convert it to markdown turned into a huge hassle. There were some automated scripts that got me 95% there but nothing worked perfectly. Manually updating all the posts was not something I wanted to do, so eventually I gave up the dream of moving that blog.

Recently I started thinking about this again, and realized there was a solution I hadn't considered. I could continue maintaining the WordPress server but set it up to publish a static mirror and serve that with GitLab Pages (or Github Pages if you like). This would allow me to automate LetsEncrypt certificate renewals as well as eliminating the security concerns associated with hosting a WordPress site. This WOULD however mean comments would stop working, but that feels like a minor loss in this case because the blog did not garner many comments.

Here's the solution I came up with and so far it seems to be working pretty well.

  • Host WordPress site at URL that is not linked to from anywhere else to reduce the odds of it being exploited - in this example we'll use http://private.localconspiracy.com (even though this site is actually built with Pelican)
  • Set up hosting on GitLab Pages for the public URL, https://localconspiracy.com
  • Add a cron job that determines when the last-built date differs between the two URLs - if the build-dates differ, mirror the WordPress version
  • After mirroring with wget, update all links from "private" version to "public" version
  • Do a git push to publish the new content

These are the two scripts I use:

check-diff.sh (called by cron every 15 minutes)

#!/bin/bash

ORIGINDATE="$(curl -v --silent http://private.localconspiracy.com/feed/ 2>&1|grep lastBuildDate)"
PUBDATE="$(curl -v --silent https://www.localconspiracy.com/feed/ 2>&1|grep lastBuildDate)"

if [ "$ORIGINDATE" !=  "$PUBDATE" ]
then
  /home/doc/repos/localconspiracy/mirror.sh
fi

mirror.sh:

#!/bin/sh

cd /home/doc/repos/localconspiracy

wget \
--mirror \
--convert-links  \
--adjust-extension \
--page-requisites  \
--retry-connrefused  \
--exclude-directories=comments \
--execute robots=off \
http://private.localconspiracy.com

git rm -rf public/*
mv private.localconspiracy.com/* public/.
rmdir private.localconspiracy.com
find ./public/ -type f -exec sed -i -e 's|http://private.localconspiracy|https://www.localconspiracy|g' {} \;
find ./public/ -type f -exec sed -i -e 's|http://www.localconspiracy|https://www.localconspiracy|g' {} \;
git add public/*
git commit -m "new snapshot"
git push origin master

That's it! Now when the blog is changed, within 15 minutes the site will be mirrored to a static version and then pushed up to the repo where it will be reflected in GitLab pages.

This concept could be extended a little further if you wanted to run WordPress locally. In that case you would not need a server to host your WordPress blog, you could just run it on your local machine. In that scenario there's no chance of your blog getting exploited. As long as you can run wget against it locally you could use the same approach outlined above to have a WordPress site hosted on GitLab Pages.


Backing up your machines

Wed October 11 2017 by Christopher Aedo

UPDATE: OSX Catalina introduced new security around disk access which prevented borg from accessing some directories. I documented a fix for that here.

TL;DR After CrashPlan discontinued their home plan I found a good solution using open source software and an inexpensive yet reliable cloud storage provider. I've got …

read more

Delivering a keynote at OSCON 2017

Sat May 27 2017 by Christopher Aedo

Working as a developer advocacy program director for IBM, improving how the world of developers perceive our company is my top priority. One of the ways I believe we can make a huge impact is by using our time in front of developers wisely. That means no product pitches at …

read more

You need a better firewall

Mon February 03 2014 by Christopher Aedo

picture

A long long time ago I had Verizon FiOS installed at my home, and with it they supplied an Actiontec router and wireless access point. It worked reasonably well, but it needed a power cycle every now and then and any custom configuration was difficult. I could never get it …

read more

Treehouse

Mon May 27 2013 by Christopher

moonrise kingdom treehouse

When I was little, we had a tree house we could play in.  It was a fantastic place to hang out for long stretches, and provided an excellent foundation for countless games of imagination.  I'm pretty sure it was mostly a space ship, but it was probably also a pirate …

read more

Sitting on your ass is killing you

Sun October 21 2012 by Christopher Aedo

This is not the first time I've said don't watch TV, or don't sit at work.  But this new article from NY times references some new studies that make the dangers of lethargy all the more vivid.

"Every single hour of television watched after the age of 25 reduces the …

read more

No news is good news

Wed September 26 2012 by Christopher

"Chances are you have one of the most insidiously dangerous objects ever created ' and one of the State's most powerful tools of domination ' in your living room right now. You may very well have one in your bedroom, too, and in your basement.
It's insidious because most Americans don't think …

read more

Better living through chemistry

Wed September 26 2012 by Christopher Aedo

It's absolutely amazing what big pharma gets away with, but it seems like so few people are aware or the least bit concerned.  We might never know how many people Merck & Co. killed with Vioxx (maybe half a million?).  The more you read, the more you find one scary story …

read more

1984, surveillance framework and your permanent record

Thu August 16 2012 by Christopher Aedo

Now THIS one definitely sounds appropriate for a blog with "conspiracy" in the title!  I've been collecting a bunch of related stories for several months now with the intention of turning it into a blog post.  Sadly I've had way too much other stuff to do lately, so I thought …

read more

Inspired by our founders

Tue August 14 2012 by Christopher

"AMERICA has a proud history of drinking on the job. Craftsmen who built the first government buildings in the 17th century were sometimes paid in brandy. The 19th-century railroaders who laid the foundations of modern America were notoriously thirsty."

The Economist

Obviously for the sake of our country I need …

read more