I want to have a discourse forum.
Why? Because I find discourse quite interesting and I like learning new things. And discourse is a new cool thing, afterall.
Anyhow, this is not a post about why I like discourse. This is a technical post about how to host discourse on your own VPS as cheap as possible, how to setup a (imho) decent nginx server in front of discourse, and how to make use of some of nginx’s features.
This post shows the steps that I took. If you think anything was forgotten or found some flaws in my configs please do comment here, or send me an email about it!
If you know how to these things cheaper that my current costs please do comment here, or send me an email about it!
Hopefully the final note you have been warned from the beginning that this is not a simple task. (though if you really are reading my blog you most likely are no computer illiterate, so you may as well continue).
TL/DR: The price
Right now it costs me 2.37 euro per month (VAT included) to host this website.
All the money is spent for hosting: a Scaleway Start1-XS VPS.
The emailing is handled using Elastic Email’s basic plan which is free and gives me 5000 emails per day.
DNS is handled by Cloudflare.
SSL (because it’s 2018 and i’ll call you ugly and stupid otherwise) certificates are free from LetsEncrypt.
This price does not include the costs of owning my domain, nor the work that I put into maintaining the server and the discourse instance (which is less than 8 hours per month) – everything IS and should be automated.
And if you think that’s costly then I have to mention that you can use the VPS also as a VPN since you have unlimited bandwidth, and you can also test about anything you can think of since you have an always-on always-waiting machine!
To host any website (forum or otherwise) you need a domain. Mine’s tbp.land and has multiple subdomains. It’s your job to find a domain that you like. In all my examples i will use my domain, and you should change that to your own.
I am using the latest Ubuntu LTS version, so the explanations here are given for this OS. Do note that discourse advices that you should use ubuntu and not centOS/arch/etc.
I am using only SSH auth using public/private keys, and no username/pass authentication. Scaleway let’s you add the public keys created using putty on windows. This is their guide, and i don’t believe i can do a better job of explaining the process.
Afterwards, you can login by using the public IP address of your sever, username root and the private ssh key you created using putty.
Installing discourse standalone
Before making everything awesome (and using the server for hosting more than discourse) i think following the basic standalone 30 minutes installation guide provided by discourse is the best.
I chose this variant as you have to make sure that discourse actually works on your server, and that you have https working properly for a few days. (if you think https is useless then i’ll remind you that you’re ugly and stupid)
There is some software which is needed for any discourse installation
- make sure your system is up to date:
sudo apt update && sudo apt dist-upgradeand chose
wget -qO- https://get.docker.com/ | sh
- turn on automatic security updates:
dpkg-reconfigure -plow unattended-upgrades(you do want everything automated)
Optional software that I find useful
glances (a system monitor):
curl -L https://bit.ly/glances | /bin/bash
Is your discourse instance working properly in standalone?
Then i think you should make it work first. There is no point in continuing the advanced part of even the basics are failing.
There are a lot of answers and discussions on the official discourse forum, and everybody there is nice.
Yep, my forum is up and running and i added some plugins as well!
- Perfect! Then we can finally put on the big boy pants and start installing nginx.
???. DNS: Cloudflare
This one should come later in the explanation.
Why did i chose cloudflare?
Because i never used it before and i wanted to know what it is. I won’t try to argue that i know much more about DNS than before, but something’s more than nothing, right?
I find cloudflare interesting. And free. Did i mention I run this server reaaaaly cheap?
Well Cloudflare offers both DNS and CDN (though in my and other’s experiences, you shouldn’t enable CDN for discourse or you will get into caching troubles!).
My usage for cloudflare is rather minima: i just use it to handle the DNS part of my server. (You may call my usage a “redirect machine”)