<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SysOps &#8211; Random Insanity</title>
	<atom:link href="https://randominsanity.net.nz/tag/sysops/feed/" rel="self" type="application/rss+xml" />
	<link>https://randominsanity.net.nz</link>
	<description>Random Insanity since 1981</description>
	<lastBuildDate>Thu, 03 Sep 2020 22:32:43 +0000</lastBuildDate>
	<language>en-NZ</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.6</generator>
	<item>
		<title>Automating Letsencrypt renewals with DNS-01 challenges</title>
		<link>https://randominsanity.net.nz/2018/03/automating-letsencrypt-renewals-with-dns-01-challenges/</link>
					<comments>https://randominsanity.net.nz/2018/03/automating-letsencrypt-renewals-with-dns-01-challenges/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sat, 24 Mar 2018 22:48:47 +0000</pubDate>
				<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Certbot]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[DNS-01]]></category>
		<category><![CDATA[Letsencrypt]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[SysOps]]></category>
		<guid isPermaLink="false">https://randominsanity.net.nz/?p=1746</guid>

					<description><![CDATA[<p>Letsencrypt and certbot are great for getting SSL certificates, however, if you're using DNS-01 it's not easy to automate renewals. I decided to fix that, at least for my use case with CloudFlare.</p>
<p>The post <a rel="nofollow" href="https://randominsanity.net.nz/2018/03/automating-letsencrypt-renewals-with-dns-01-challenges/">Automating Letsencrypt renewals with DNS-01 challenges</a> appeared first on <a rel="nofollow" href="https://randominsanity.net.nz">Random Insanity</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Preface</h2>
<p>When researching options before writing the code referred to in this article, I came across a comment from someone I understand to be involved in the admin/author side of certbot. While I can&#8217;t find the link any more, they basically replied to someone stating that certbot would never provide plugins for DNS providers, which made sense since there are so many. However, shortly after finishing off this software, I came across the shiny new release of certbot, which  has some pre-written plugins for, you guessed it, DNS providers.</p>
<p>These plugins are not yet packaged for Ubuntu, so while I tried to do a quick test, I ended up still using my new script. If you&#8217;re starting out with certbot 0.22.0 or higher and get their plugins, they are probably a better option however this stuff will still work and is an option for you. And I&#8217;ll keep the code live for anyone who wants it, if for no other reason than it&#8217;s something else others can pick as an example to learn things from.</p>
<h2>Introduction</h2>
<p>Many of you will have heard of <a href="https://letsencrypt.org/">Letsencrypt</a>, a service that enables creation of SSL certificates for use on websites (and anywhere else technically) for free; cost being one of the barriers to wider adoption of secured websites. I use this service for several sites, including this one.</p>
<p><img loading="lazy" class="alignright size-thumbnail wp-image-1748" src="https://randominsanity.net.nz/wp-content/uploads/certbot-logo-1A_large-150x55.jpg" alt="" width="150" height="55" srcset="https://randominsanity.net.nz/wp-content/uploads/certbot-logo-1A_large-150x55.jpg 150w, https://randominsanity.net.nz/wp-content/uploads/certbot-logo-1A_large-300x110.jpg 300w, https://randominsanity.net.nz/wp-content/uploads/certbot-logo-1A_large.jpg 630w" sizes="(max-width: 150px) 100vw, 150px" />I had a particular issue when it came to certificate renewal time that wasn&#8217;t supported automatically. In this post, I&#8217;ll explain a little about Letsencrypt and its client application certbot, and about &#8220;<a href="https://certbot.eff.org/docs/challenges.html">challenges</a>&#8221; which are how Letsencrypt verifies you should be given a certificate you ask for. I&#8217;ll only be dealing with the authentication side of certbot: while it and a number of other clients are able to install the certificates for you as well, I did this part manually to fit within my Nginx configuration the way I wanted, but there is plenty of information out there if you want to learn more about that side.</p>
<h2>My Setup</h2>
<p>If you&#8217;ve read my previous posts you&#8217;ll likely have an idea of this already, but a simple overview for those who haven&#8217;t.</p>
<p>I run my domains on servers hosted in AWS on Ubuntu servers. I use <a href="https://www.nginx.com/">Nginx</a> (Open Source Version) as a hosting and proxying platform. My websites are, for the most part, exposed via <a href="https://www.cloudflare.com/">CloudFlare</a> (Free Tier).</p>
<p>For me, these certificates are securing the leg between CloudFlare and my server so users don&#8217;t normally see them, but they form one leg of the end-to-end security chain..</p>
<h2>Letsencrypt</h2>
<p><img loading="lazy" class="alignright size-thumbnail wp-image-1772" src="https://randominsanity.net.nz/wp-content/uploads/78ccd985-50e6-4e20-9e2b-d6ae61814704-150x39.png" alt="Letsencrypt Logo" width="150" height="39" srcset="https://randominsanity.net.nz/wp-content/uploads/78ccd985-50e6-4e20-9e2b-d6ae61814704-150x39.png 150w, https://randominsanity.net.nz/wp-content/uploads/78ccd985-50e6-4e20-9e2b-d6ae61814704-300x77.png 300w, https://randominsanity.net.nz/wp-content/uploads/78ccd985-50e6-4e20-9e2b-d6ae61814704.png 700w" sizes="(max-width: 150px) 100vw, 150px" />Letsencrypt can be managed by a number of software clients, however, the main one and the one I use is called <a href="https://certbot.eff.org/">certbot</a>. Certbot allows the issuing of new certificates and the renewal of existing ones; renewal being important because the main caveat of these certificates is that they are only valid for 90 days. And the key part of this process is validating ownership in a challenge/response style setup, which can be done 3 different challenge methods.</p>
<h3>HTTP-01</h3>
<p>Probably the most common or most easily achieved method of validating your domain is HTTP-01. It involves posting a specified file in a specified location on the website. There are plugins for certbot that make this really easy for a number of hosting setups, including Nginx which I run.</p>
<p>For me, this wasn&#8217;t so practical. As I mentioned the DNS wasn&#8217;t pointing to the new server yet, and I didn&#8217;t want to mess around putting stuff on the old servers. Also, I had an additional site that I wanted a certificate for but I wasn&#8217;t able to modify the content to support this method.</p>
<h3>TLS-SNI-01</h3>
<p>I haven&#8217;t actually heard of anyone using this in the wild, and I haven&#8217;t tried it as it&#8217;s not functional when using CDN in front of your servers.</p>
<h3>DNS-01</h3>
<p>So this is the one I chose. DNS-01 involves adding a TXT record to your DNS with the specified value. For me this was great, it didn&#8217;t matter where my website was pointed yet, or if I could modify files. Because I could edit the DNS this way I was able to ensure zero downtime getting the certificates issued and in place before I did the cutover.</p>
<h2>The downside to DNS-01</h2>
<p>DNS-01 got me going well, however, when it comes to renewal time it&#8217;s not something that can be automatically supported. HTTP-01 has various options and settings to dump files in a specified location to automate that, but DNS is much more diverse and not all providers even offer an API. I gave it some thought and confirmed for my self that I couldn&#8217;t change to HTTP-01, mainly as I had this system issue certificates for domains that didn&#8217;t point to this server still (yeah maybe I&#8217;m a special case, but it is what it is).</p>
<p>Certbot has hooks to do things before and after any validation steps, so I decided I&#8217;d make it automated myself!</p>
<h2>Automating DNS-01 challenges with CloudFlare</h2>
<p>CloudFlare offers a great API, even on its free tier, so I decided to write a hook to automate the necessary updates. Since I&#8217;m that way inclined too, I&#8217;ve made it freely available, hosted <a href="https://bitbucket.org/logicalroute/certbot-cloudflare-dns-hook/">here</a>.</p>
<p>Basically, it&#8217;s a NodeJS script that runs through the following logic:</p>
<ul>
<li>Given a domain and a validation code</li>
<li>Get a list of the users&#8217; domain zones from CloudFlare and find which one is appropriate for this domain</li>
<li>Check that zone to see if we already have an &#8216;_acme-challenge&#8217; TXT record for the domain</li>
<li>If we don&#8217;t create it. If we do, update it. In both cases, set it to the validation code provided.</li>
<li>Query DNS and see if it&#8217;s updated yet and if not, look at the TTL for the query and wait that long plus a 10-second buffer and try again up to a configurable number of times until it is updated.</li>
<li>Done.</li>
</ul>
<p>This basically sets up the new validation information and waits until it is deployed, then returns allowing certbot to do it&#8217;s check and provided that succeeds, get the newly issued certificates. Now, of course, I&#8217;m simplifying a few things. It&#8217;s not certbot doing ALL the validation etc, but between certbot and the server they work it out; the finer detail isn&#8217;t too important for us just here.</p>
<p>What you get in the end is the ability to run a command like the following, and have it automatically manage the DNS-01 challenge setups required, which means it can be put into a cron job and not require manual intervention every couple of months!</p>
<pre>sudo certbot renew --manual --manual-auth-hook "/path/to/node /path/to/hook.js"</pre>
<p>As it turns out, the hook can also be used for certonly certificate issuing; it creates and manages validation just as well as the renew does. There is more detail and examples for installation and usage in the <a href="https://bitbucket.org/logicalroute/certbot-cloudflare-dns-hook/src/master/README.md">readme</a> file in the code repository so if you want to check it out that&#8217;s a good next place to look.</p>
<h2>Summary</h2>
<p>Wow, that was a lot longer way of saying &#8220;I made a script to support DNS-01 challenge automation on certbot manual renewals&#8221; than I expected&#8230;</p>
<p>Anyway, please feel free to check it out, have a look at the <a href="https://bitbucket.org/logicalroute/certbot-cloudflare-dns-hook/src/master/README.md">readme</a> which has some helpful info on getting it going, and I&#8217;ll try to address any questions or issues that come up. It&#8217;s far from perfect, but it works well for me so for now, it&#8217;ll do. Perhaps in the future I&#8217;ll try and improve any error handling etc. but no doubt that&#8217;ll come if I start seeing more errors I need to handle!</p>
<p>If you manage a website and you don&#8217;t have it secured with SSL, <strong>DO IT</strong>!!! There really is no good reason not to anymore.</p>
<p>Thanks for reading!</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2018%2F03%2Fautomating-letsencrypt-renewals-with-dns-01-challenges%2F&amp;linkname=Automating%20Letsencrypt%20renewals%20with%20DNS-01%20challenges" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2018%2F03%2Fautomating-letsencrypt-renewals-with-dns-01-challenges%2F&amp;linkname=Automating%20Letsencrypt%20renewals%20with%20DNS-01%20challenges" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2018%2F03%2Fautomating-letsencrypt-renewals-with-dns-01-challenges%2F&amp;linkname=Automating%20Letsencrypt%20renewals%20with%20DNS-01%20challenges" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2018%2F03%2Fautomating-letsencrypt-renewals-with-dns-01-challenges%2F&amp;linkname=Automating%20Letsencrypt%20renewals%20with%20DNS-01%20challenges" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Frandominsanity.net.nz%2F2018%2F03%2Fautomating-letsencrypt-renewals-with-dns-01-challenges%2F&#038;title=Automating%20Letsencrypt%20renewals%20with%20DNS-01%20challenges" data-a2a-url="https://randominsanity.net.nz/2018/03/automating-letsencrypt-renewals-with-dns-01-challenges/" data-a2a-title="Automating Letsencrypt renewals with DNS-01 challenges"></a></p><p>The post <a rel="nofollow" href="https://randominsanity.net.nz/2018/03/automating-letsencrypt-renewals-with-dns-01-challenges/">Automating Letsencrypt renewals with DNS-01 challenges</a> appeared first on <a rel="nofollow" href="https://randominsanity.net.nz">Random Insanity</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://randominsanity.net.nz/2018/03/automating-letsencrypt-renewals-with-dns-01-challenges/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Migrating WordPress to AWS Lightsail (and other related changes) – Part 2</title>
		<link>https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2/</link>
					<comments>https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Thu, 28 Dec 2017 08:14:09 +0000</pubDate>
				<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SysOps]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://randominsanity.net.nz/?p=1735</guid>

					<description><![CDATA[<p>In part 1 I gave a bit of background and discussed moving the website hosting for two of my sites. In part 2 I&#8217;ll discuss domains&#8230; Thrilling stuff!&#60;/sarcasm&#62; Domains I thought domains would be easy. I have a pretty good understanding of domain registration and DNS, having worked with them for years so I went&#8230;</p>
<p>The post <a rel="nofollow" href="https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2/">Migrating WordPress to AWS Lightsail (and other related changes) – Part 2</a> appeared first on <a rel="nofollow" href="https://randominsanity.net.nz">Random Insanity</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In <a href="https://randominsanity.net.nz/?p=1730">part 1</a> I gave a bit of background and discussed moving the website hosting for two of my sites. In part 2 I&#8217;ll discuss domains&#8230; Thrilling stuff!&lt;/sarcasm&gt;<span id="more-1735"></span></p>
<h3>Domains</h3>
<p>I thought domains would be easy. I have a pretty good understanding of domain registration and DNS, having worked with them for years so I went looking for a new registrar. I needed to relocate registration and hosting of both domains, and my main requirements looking around were ease of management and price.</p>
<p>As I mentioned in my previous post, I&#8217;d already settled on Amazon Lightsail for my site hosting, so Amazon seemed a good option for DNS to keep it all together also.</p>
<p>While the web hosting was basically identical for the 2 sites, the domain portion has a little (only a little) variety.</p>
<h4>RandomInsanity.net.nz</h4>
<p>As the first of the 2 sites I moved, I jumped into AWS Route53 and set up my DNS settings. Quite easy, and as best I can tell, will at worst cost me a couple of bucks a month if there are lots of requests (I&#8217;m thinking spamming etc; I don&#8217;t expect my readership to be that large!).</p>
<p>I also used Route53 and transferred my domain hosting over. Pretty easy, although it gave me some messages about my current provider having to approve it etc. which in the end I suspect is a just half generic warning for some other registries that require that. Route53 wasn&#8217;t the cheapest registrar I&#8217;d found here, but for ease of management, I thought I&#8217;d just keep it all together.</p>
<p>The one thing I&#8217;ll note is to keep an eye on your email. They send you info and anything you need to do which may not always be obvious on the console.</p>
<h4>SaferHomes.nz</h4>
<p>After randominsanity.net.nz being so easy, I planned to so saferhomes.nz the same way. And then I hit the real world.</p>
<p>The easier part first: instead of the Route53 hosting of the domain records, I used the inbuilt DNS part of Lightsail which as best I can tell has no particular additional charge beyond the Lightsail plan I was on. Same general result but different management location. Cool, done.</p>
<p>And then I went to transfer the domain.</p>
<p>Despite <strong>.nz</strong> having been commonplace for New Zealand for a couple of years now, it seems Route53 does not support this top-level domain (the support .co.nz, .org.nz, .net.nz, but plain old .nz). <a href="http://gandi.net/">Gandi</a>, the registrar AWS state they use supports it, but AWS themselves don&#8217;t. Bugger.</p>
<p>At first, I thought I must be doing something wrong, but after a while, I&#8217;d found numerous forum posts asking AWS when they would support it, right back from when it first became available, with no commitment beyond &#8220;it&#8217;s on our backlog&#8221;. Amazon&#8217;s own documentation, when you dig deep enough, has a list of the TLD&#8217;s (Top Level Domains) that they support and .nz is not listed.</p>
<p>So, there goes my plan of keeping it all together. In the end, I have moved the registration to <a href="https://www.domains4less.co.nz">Domains4Less</a> and then just entered the AWS name servers for the domain into the records. Not ideal, but it seems to be working well.</p>
<h3>Email</h3>
<p>The email was much easier in the end. I actually had saferhomes.nz using Google&#8217;s GSuite already so I left it where it was.</p>
<p>For randominsanity.net.nz, my initial thought was that I would just find a way to forward it all to a Gmail account I currently tie my personal address in with. However, until now, I&#8217;d been basically using a full email account on my ISP network, with Gmail just grabbing email using POP and sending to that user using SMTP. Given I wanted to kill that mailbox, that wasn&#8217;t going to work.</p>
<p>I probably spent a couple of hours looking at solutions. Ideally just finding somewhere that&#8217;d charge me bugger all to do a blind mail relay for my domain, but that wasn&#8217;t really a service in wide supply. I looked at Amazon services, using their Simple Email Service which short of using a lot of work (S3 buckets and Lambda functions) probably wasn&#8217;t going to do what I wanted nicely anyway.</p>
<p>In the end, I just bit the bullet and setup another GSuite account for it. It costs me $5 to have my mailbox. I could have used Amazon&#8217;s WorkMail feature for a similar price but it didn&#8217;t look as polished as Gmail/GSuite so I erred on staying with the option I was familiar with since I had no intention of moving the saferhomes email.</p>
<h2>Summary</h2>
<p>Well, that&#8217;s really it at present. Maybe there won&#8217;t be a part 3&#8230;</p>
<p>In short, this is what I&#8217;ve ended up with:</p>
<h4>RandomInsanity.net.nz</h4>
<ul>
<li>Domain Registration: Amazon Route53</li>
<li>Domain Hosting: Amazon Route53</li>
<li>Website Hosting: Amazon Lightsail</li>
<li>Email Hosting: Google GSuite</li>
</ul>
<h4>SaferHomes.nz</h4>
<ul>
<li>Domain Registration: Domains4Less</li>
<li>Domain Hosting: Amazon Lightsail</li>
<li>Website Hosting: Amazon Lightsail</li>
<li>Email Hosting: Google GSuite</li>
</ul>
<p>SSL was a bit of a mission, and I can&#8217;t say I&#8217;m 100% on exactly which bit resolved it but it can be done. Basically following various Bitnami documentation.</p>
<p>Outbound email required configuration of SMTP credentials in WordPress but once that was done it worked fine, for what I needed anyway.</p>
<p>Hopefully, someone might find this something resembling interesting, and maybe even helpful. I&#8217;ll try to provide updates as the journey continues or as my setup evolves (I may still try moving everything to a more home-grown EC2/RDS type setup, but we&#8217;ll see how we go).</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2%2F&amp;linkname=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%202" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2%2F&amp;linkname=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%202" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2%2F&amp;linkname=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%202" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2%2F&amp;linkname=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%202" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2%2F&#038;title=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%202" data-a2a-url="https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2/" data-a2a-title="Migrating WordPress to AWS Lightsail (and other related changes) – Part 2"></a></p><p>The post <a rel="nofollow" href="https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2/">Migrating WordPress to AWS Lightsail (and other related changes) – Part 2</a> appeared first on <a rel="nofollow" href="https://randominsanity.net.nz">Random Insanity</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Migrating WordPress to AWS Lightsail (and other related changes) &#8211; Part 1</title>
		<link>https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1/</link>
					<comments>https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1/#comments</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Thu, 28 Dec 2017 08:07:12 +0000</pubDate>
				<category><![CDATA[Geekery]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SysOps]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://randominsanity.net.nz/?p=1730</guid>

					<description><![CDATA[<p>As some of you will know, my position with my current employer has recently been &#8220;disestablished&#8221;. I won&#8217;t go into the story around that, at least at this point, however as part of my preparing to leave I&#8217;ve been working on moving all my services away from said employer (an ISP). Besides the obvious Broadband,&#8230;</p>
<p>The post <a rel="nofollow" href="https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1/">Migrating WordPress to AWS Lightsail (and other related changes) &#8211; Part 1</a> appeared first on <a rel="nofollow" href="https://randominsanity.net.nz">Random Insanity</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As some of you will know, my position with my current employer has recently been &#8220;disestablished&#8221;. I won&#8217;t go into the story around that, at least at this point, however as part of my preparing to leave I&#8217;ve been working on moving all my services away from said employer (an ISP).<span id="more-1730"></span></p>
<p>Besides the obvious Broadband, I&#8217;ve got 2 websites (well, more than 2 but only 2 I&#8217;m going to keep alive) and a number of domains, as well as some email hosting. Moving all this has been a bit of a mixed journey and although it&#8217;s still going on, I thought I&#8217;d start putting together a bit of the story, challenges, lessons, solutions etc. for anyone else who is looking at moving such things for themselves.</p>
<p><em>After getting part way through this article, I realised how long it was getting, so I&#8217;m going to break it down into parts. Part 1 will be websites, <a href="https://randominsanity.net.nz/?p=1735">part 2</a> will cover the rest.</em></p>
<h2>TL;DR</h2>
<p>I moved 2 WordPress sites to Amazon Lightsail, mail to Google GSuite, and domains are still a work in progress with domain hosting being a mix of AWS Route53 and Lightsail, and domain registration being AWS Route53 and Domains4Less. Do you want to know why? Read!</p>
<h2>The story</h2>
<p>After 11 years at my current work, I&#8217;d just tended to keep all the things I could in our systems. Partially because I built said systems so had great control/flexibility/etc. and partially because, for the most part, it cost me nothing. So as part of leaving, rather than keeping everything in place and paying their advertised rates, I decided a move was necessary!</p>
<p>For the purpose of this post, I&#8217;ll concentrate on 2 domains. The first one &#8220;randominsanity.net.nz&#8221; (AKA, this site) is my personal stuff, blog, email, basic. The second is a business domain &#8220;saferhomes.nz&#8221; (A company I&#8217;m a co-founder of). For both, we&#8217;ll look at domain, website and email (not necessarily in that order mind you).</p>
<h3>Websites</h3>
<p>As the generally larger part of the project, I started looking for a new web host first off. Both the sites I&#8217;m dealing with are WordPress, currently hosted using Plesk on my employers&#8217; web server.</p>
<p>I looked at various locations, both web hosting and straight out VPS, with varying cost and resources. I liked the VPS idea in that I could probably just run both sites (they are pretty low traffic) on one server; I&#8217;ve certainly got the sysadmin skills to run the server and manage all that so why pay for someone else doing that stuff! In the end VPS still looked like it would end up more expensive than just outright hosting in many instances.</p>
<p>Due to already evaluating <a href="http://aws.amazon.com">AWS</a> for another project recently, this was one of the places I looked, almost out of pure curiosity more than serious intent. While the pricing on AWS can be quite hard to piece together, best I could tell I could probably do what I needed within their free tier (at least for the first year) and costs wouldn&#8217;t be tooooo huge beyond that.</p>
<p>So, I could setup a server on EC2, run a MySQL database on RDS, and even do a bunch of my DNS on Route53 (we&#8217;ll talk more about DNS soon). Appealing, not overly difficult concept, and just enough new stuff to make it an interesting challenge. However, as one might imagine, with less than 4 weeks of employment left, a job hunt in the works, a mortgage and all the other bills one acquires as part of being an adult, I came to the conclusion that I wanted something a little faster and easier, with less thinking.</p>
<p>Still, AWS had strong appeal as I wanted to do more there in future. Then I spotted Amazon Lightsail. Almost a sub-service of AWS, accounts linked but designed to be nicely functional for those not dealing with the normal AWS console. Lightsail touts a low-end plan of $5 (US) per month and the ability to deploy a pre-configured WordPress site, which I took an educated guess I&#8217;d be able to migrate my current sites overtop of without too much effort.</p>
<p>So Lightsail it was.</p>
<p>I started with my personal domain as a guinea pig first (experiments are rarely good on business domains). A new AWS account was easy to setup, and jumping over to Lightsail I had a generic WordPress site going in about 5 minutes flat.</p>
<p>Lightsail gives you a dedicated IP address for your container (I consider their deployed site/server as a container &#8211; maybe I&#8217;ve just been playing in the docker space for too long) which you can use to access your website before sorting any DNS; a nice way to be able to prep the site before migration.</p>
<p>The first gotcha I realised in Lightsail is that although you get a public IP, it&#8217;s my understanding (from reading rather than having his the issue) is that the IP they allocate is dynamic, which I assume means either that a new IP may get allocated of you restart the container, or (and this is probably more likely) that it&#8217;s a little like EC2 where you could kill and redeploy the container but you&#8217;d lose the ability to get the same IP again. While the latter wasn&#8217;t a major likelihood for me, in case it was the former, I made use of the easy spot in Lightsail to create a Static IP which I can then point to my container and use henceforth. A quick note for young players, while the Static IP is free (for up to 5), it will get charged if you don&#8217;t have it attached to a container!!</p>
<p>Okay, so I have WordPress running and accessible&#8230; now how to get all my content across?</p>
<p>I had a quick go with WordPress&#8217;s inbuilt export/import. That moved all my posts across just fine, but then the theme I was using no longer seemed to be available from WordPress. Cool, copy the theme directory over&#8230; nope, seems I&#8217;d done some customisation of the theme which I couldn&#8217;t recall, so the theme looked quite different out of the box.</p>
<p>Right, plan B (there&#8217;s always a plan B, and as is often the case, it was Google). Rather than reinvent the wheel, a quick Google confirmed I wasn&#8217;t the first to have this mission (Shock!), nor the first to document a little of the journey for the benefit of others. You can find the article I read <a href="https://worstwriter.com/2016/02/09/a-very-beginners-guide-to-migrating-hosting-wordpress-on-aws/">here</a>, but basically there is lovely plugin for WordPress (All-in-One WP Migration &#8211; love the creative naming) that does a really good and complete site export/import. Install the plugin at each end and follow your nose!</p>
<p>The one trick I did find during export was that since I was keeping the same domain, under the advanced options on the export screen I selected &#8220;Do not replace the email domain&#8221; as well as &#8220;Do not export spam comments&#8221;. Other than that it was plain sailing!!</p>
<p>Saferhomes.nz was pretty much identical. Although, while I chose the advanced export options on my first site, when it came to the saferhomes domain I forgot them and it caused a sufficient headache on the other end that I actually went back and re-did the export with them selected. If you&#8217;re changing domain I don&#8217;t expect it&#8217;ll be such an issue but it certainly helped for just moving the domain to another).</p>
<p>With saferhomes.nz though I have an additional challenge. Under Plesk I had it using <a href="https://letsencrypt.org">Letsencrypt</a> to automatically get and keep an SSL certificate up-to-date. Lightsail&#8217;s WordPress has no such easy feature, and it uses a custom server setup for WordPress and Apache from Bitnami. SSL is a must on this site, so I&#8217;m currently working on getting Letsencrypt running in this new landscape. It&#8217;s a work in progress, but I&#8217;ll ether make a new post on how I succeeded (yes, I&#8217;m backing myself to crack it) once I finish.</p>
<p>Other than that, 2 websites running on Lightsail and accessible via IP!</p>
<p>Wow, that&#8217;s a lot. Stay tuned (or go look) for <a href="https://randominsanity.net.nz/?p=1735">parts 2</a> and probably 3 in due course.</p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1%2F&amp;linkname=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%201" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1%2F&amp;linkname=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%201" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1%2F&amp;linkname=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%201" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1%2F&amp;linkname=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%201" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Frandominsanity.net.nz%2F2017%2F12%2Fmigrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1%2F&#038;title=Migrating%20WordPress%20to%20AWS%20Lightsail%20%28and%20other%20related%20changes%29%20%E2%80%93%20Part%201" data-a2a-url="https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1/" data-a2a-title="Migrating WordPress to AWS Lightsail (and other related changes) – Part 1"></a></p><p>The post <a rel="nofollow" href="https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1/">Migrating WordPress to AWS Lightsail (and other related changes) &#8211; Part 1</a> appeared first on <a rel="nofollow" href="https://randominsanity.net.nz">Random Insanity</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://randominsanity.net.nz/2017/12/migrating-wordpress-to-aws-lightsail-and-other-related-changes-part-1/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
