Alrighty, this is a simple tutorial on how to get up and running with HTTPS on a virtual server, but it assumes that you’re running Virtualmin on a VPS. If you don’t yet know what either of those two things are, give them a Google — Both of ’em will make your life much easier if you manage multiple websites or apps and/or do a bit of hosting. FYI, this VPS is running Ubuntu and Apache, so some screenshots may differ if you’re using CentOS with NGINX or something else.
Challenge Accepted.
Log into Virtualmin with your root account, and select the virtual server that you want to secure with HTTPS. Open the Enabled Features panel and check SSL website enabled then click Save Virtual Server
Next, in the menu panel on the left, Click Server Configuration > Manage SSL Certificate
Piece of cake. Click the Let’s Encrypt tab and you can add your domain & www.yourdomain to the Domain Names Listed Here box, I didn’t personally bother with mail — a) because it didn’t work and b) because if you’re successfully running your own mail server, there’s no way you’re reading this tutorial.
For Months between automatic renewal I just leave it set to the default of auto-renewing the certificate, because who wants to do that manually.
Q: Great! We’re done now, right?
A: Wrong. But almost — we just need to tidy up a bit.
And this is where we do that. Now, if you’re on Ubuntu it’s your lucky day. If you aren’t – the path may be different, but the process should be the same. In an FTP-capable app such as Coda 2 navigate to /etc/apache2/sites-available/{{yoursite}}.conf, as pictured. Open it up, then look for the following ‘VirtualHost’ bits of code.
<VirtualHost *:80>
// Lotsa Junk Here
</VirtualHost>
<VirtualHost 127.0.0.2:443>
// Lotsa Junk Here
</VirtualHost>
The problem here is that second part.
127.0.0.2:443
The reason for this is that Apache is using the default internal I.P of the server instead of our site’s address – that’s bad. We need to change that to match the url of our site so that the server will know where to send the request, like so:
<VirtualHost makeswebsit.es:443>
// Lotsa Junk Here
</VirtualHost>
Now with that done, we are pretty much good to go. Check back into Virtualmin then click on the Webmin icon. In the Webmin area, click Servers > Apache Webserver — check the virtual server you want to update and click the Apply Changes button in the top right corner. This will restart apache and update your new settings.
And that’s it, you’re secured!