Abhik Jain blog github about

Site Setup

UPDATE: checkout my new post on how I moved to vercel and serverless for my needs, hosting things basically for free. All of this has not been updated, and may be wrong.

Please read the entire blog post from start to finish atleast once before starting out and buying out domain and/or hosting. If documentation of any of the tools or services I used here differs from what I say about them here, then trust the documentation over me.

For setting up your own site with email, you need a domain name and a server with static IP. You can follow Luke Smith’s video for setting website and email, and also for details I am skipping here.

Getting a Domain Name

For domain name I used Namecheap as I have heard many people say that it is reliable and I got a good price. You ca choose anyone you like, just place attention to how much they charge next year to retain your domain. Sometimes these domain registrars give out domains names initially for a very cheap price but then charge a lot more compared to other domain registrars for retaining the site. So pay attention to the retain/resell price of the domain, regardless of what price they offer for the first few years.

Unlike a server which can be self hosted given a static IP, domain name registration needs to happen via one of ICANN-accredited registrar. So unless you can get yourself ICANN-accredited and then host your own DNS server or add DNS entries pointing to your IP on some other DNS servers, you probably need a registrar for registering a domain name.

You don’t need to purchase SSL certificates. There is the CertBot project which does that for you for free.

Getting a Server with static IP

For hosting I used Droplets by DigitalOcean. Don’t use use AWS as it is really difficult to set up reverse DNS records in them. For AWS Lightsail, you need to send a request to Amazon to get a Reverse DNS entry, and it is likely that they will refuse and ask you to use either Amazon’s SES or Amazon’s WorkMail. SES does not have any way to receive mails using an email client, except maybe downloading all the mails from the S3 bucket and then opening them in a email client, which is a lot of work in my opinion. You also need to pay extra for using SES and creating a S3 Bucket to store them. It is great for mass mailing, but we just want a simple personal mail. Amazon WorkMail is nice but it is also aimed for enterprise users, and costs 4$ per user. Thus you likely can not setup an email in AWS unless people at AWS accept your request to at Reverse DNS records, but why use it when other hosting services don’t require sending any such requests for the same?

I would recommend either Linode or DigitalOcean as they have excellent documentation, are relatively easy to use and provide all features needed to replicate my setup. Linode is a bit strict in the sense that you need to provide proper address details, and even if you add your credit card details they first manually verify that you are indeed a real person and your details seems to be correct before allowing you to spin up servers, and this process can take some time. It took 4-5 hours for me to get permissions, but that was because I skipped the address details. It might be faster or slower for you.

Note that if you are planning to host your own git and matrix homeserver, then you should have around 1GB RAM on your server. My server consistently uses 70% percent of the 1GM RAM, and sometimes jumps to 100% in case of occational large traffic.

You can also host your server on a device you own at home, provided you can get a static IP address for it. But then you need to ensure that your device is always up and has good connection to internet. It is not too difficult, and many people do it for hosting personal sites, but using a cloud provider is easier as they already provide you with a static IP, ensure that server is always up and do the initial setup for things like DDoS protection, firewalls, SSH, setting up static IP, adding PTR records etc. I am using a cloud provider, and rest of the blogs assumes the same. If you are planning to host your own server then you need to figure out how to perform rest of the steps which involves the server on your own.

If you are using a cloud provider instead then make sure that they have a way to add reverse DNS records (or PTR records) which does not involves asking for their permission.

Setting up your DNS records

Once you have bought a domain name from a registrar and your server is up and running with a static IP, you need to setup DNS records. Refer the Luke Smith’s video above on what records to add depending on your needs. I have anyway listed below the records that I added.

All domain name registrars have their own DNS servers, and provide you with options to add DNS records to their server once you have bought a domain name. Some cloud providers also host their own DNS servers, and they also provide you with an option to add DNS entries to their server. I know that Linode and DigitalOcean do provide this service for free. So it is upto you where you want to add your DNS entries, either at your Domain registrar or your cloud provider in case they have this option. I have added records to DigitalOcean’s DNS servers instead of ones provided at Namecheap simply because I liked the interface better. It didn’t give any real benefits in terms of speed of connection.

In case you decide to use your cloud provider’s DNS server, you will still need to add SNS records.

I needed to add A records and AAAA records for websites; a MX records, a CNAME record and TXT records for email. TTL entry you add doesn’t matter that much, so left them to default values.

A records that I added:

HostIPTTL
@, pointing to abhikjain.xyzMy servers IPv4 address3600
*, pointing to *.abhikjain.xyzMy servers IPv4 address3600
www, pointing to www.abhikjain.xyzMy servers IPv4 address3600

Similarly, I added the following AAAA records:

HostIPTTL
@, pointing to abhikjain.xyzMy servers IPv6 address3600
*, pointing to *.abhikjain.xyzMy servers IPv6 address3600
www, pointing to www.abhikjain.xyzMy servers IPv6 address3600

MX record that I added:

HostMail ServerTTL
@, pointing to abhikjain.xyzmail.abhikjain.xyz14400

CNAME record that I added:

HostAlias ofTTL
mail, pointing to mail.abhikjain.xyz@, pointing to abhikjain.xyz43200

Note that mailing actually involves 2 services: an IMAP/POP3 service which is used to receive/download emails which your server received (via SMTP) to your local client and a SMTP service which is used send mails to other SMTP servers. I host both of these on same address (mail.abhikjain.xyz) on different ports becuause I used a script for setting up mail, but it is more common to have them on seperate addresses.

TXT records for my site were given by the script that is used to setup my email.

Set up routing on your server

Even though DNS records point to your server, your server will refuse to accept any connections if you don’t. You need to setup up firewall rules to allow incoming traffic on port 22, 80 and 443 atleast. You will need to open up other ports depending upon what all things are you going to setup on your server.

Then you’ll also need to setup your webserver to host webpages for HTTP(s) ports atleast. I used nginx, but you may use any one you like, or write your own if you want. Luke Smith’s video has details on how to setup nginx.

Getting SSL Certificates

If you have bought SSL certificates from your domain registrar then you don’t need to do this step. Else use Certbot. It is super easy and nothing much to explain. Just remember to get redirection when CertBot asks whether you want it.

Do remember to get it for your mail server as well as for all sites you want to use.

Setting up basic site and E-mail

Just follow Luke Smith’s video. Use his emailwiz script to setup email. Make sure that your sites (the ones on which you want to show something) redirects to some html page for now.

Setting up self-hosted git

I used Gitea for this. You can also setup GitLab or Gogs. I’ll be assuming you are using Gitea.

Note that if you are fine with paying to host Git on a seperate server, you can use instances which are already setup in marketplaces of various cloud providers. I know that DigitalOcean and Linode provide them. If you are using the marketplace ones, that you can skip this section.

You can also first launch git from marketplace, and then build rest of your site on top of that, if you find that easier.

First you need to setup a database. I used Postgres, but you may choose any one you like which is supported by Gitea. Follow these instructions.

Then download and install the binary following these instructions and then install Gitea as a linux service using these instructions.

Setting up Matrix

I use Conduit as my matrix homeserver. It does not implement all features so you may face some issues, but it works well with low RAM. Follow the deploying instructions.

Auto Updates

I suggest setting up crontab to automatically manage your server. Your SSL cerificates will expire, Gitea or Conduit might get new updates. Read the update instructions of these and set up required cronjobs.

Also setup cronjobs to regularly take backups of the Gitea server.