Setting up your own GoToSocial instance

Up until now I had a Mastodon account on mastodon.social that I created in 2016. If you, as I do, want to own all your content IndieWeb-style, ideally it should live under a domain I own and control.

fediverse.jpg|600

That left me with three options. I could either integrate all the stuff I want to post on Mastodon on my own site and post from there to the Fediverse (that's what the IndieWeb calls POSSE), or I could grab all the content from mastodon.social and syndicate it to my site (that's PESOS). As my homepage is staticly published, both options didn't seem viable.

That leaves me with the third option, run an ActivityPub instance for my domain that federates with the Fediverse so I can publish my content there and other Mastodon users can find me.

Running a full-fledged Mastodon server instance seemed like a bit of overkill for my purposes, so luckily I found GoToSocial, a lightweight ActivityPub implementation in Go that suit my needs. It even has a nice sloth logo!



Preparations

Domain

For starters, I had to decide under which domain I want to run the instance. As my main domain is stierand.org, I wanted to run the instance there, too. To not clash with the already running website on that domain, you can set up the instance in what is called split-domain deployment. So the instance will run on social.stierand.org, but all accounts will have stierand.org as their domain.

Important

This consideration and the folliwing steps have to be done before you deploy anything. After you've federated with other servers, it's hard to change this, so take your time!

DNS entries

As I have moved all my DNS entries to Cloudflare, I now have to set up a DNS entry for social.stierand.org. This is done by the following Terraform code:

resource "cloudflare_record" "cf_stierand_dns_a_social" {
  content = "116.202.99.150"
  name    = "social"
  proxied = false
  ttl     = 1
  type    = "A"
  zone_id = var.cloudflare_zone_id
}

resource "cloudflare_record" "cf_stierand_dns_aaaa_social" {
  content = "2a01:4f8:c010:2e63::1"
  name    = "social"
  proxied = false
  ttl     = 1
  type    = "AAAA"
  zone_id = var.cloudflare_zone_id
}

As described on the page for split-domain deployment, ActivityPub queries the account domain (stierand.org in my case) with the WebFinger protocol (side note: I still remember the old Finger procotol from back in the Solaris days. Yeah, I'm old). So you have to create some glue code on your account domain that redirects to the server domain (social.stierand.org). The GoToSocial website has examples for nginx and the like, but as stierand.org runs on Apache, I had to create the necessary entries myself.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/.well-known/webfinger$ [NC]
    RewriteCond %{HTTP_HOST} ^stierand\.org$ [NC]
    RewriteRule ^(.*)$ https://social.stierand.org/$1 [R=301,L]

    RewriteCond %{REQUEST_URI} ^/.well-known/host-meta$ [NC]
    RewriteCond %{HTTP_HOST} ^stierand\.org$ [NC]
    RewriteRule ^(.*)$ https://social.stierand.org/$1 [R=301,L]

    RewriteCond %{REQUEST_URI} ^/.well-known/nodeinfo$ [NC]
    RewriteCond %{HTTP_HOST} ^stierand\.org$ [NC]
    RewriteRule ^(.*)$ https://social.stierand.org/$1 [R=301,L]
</IfModule>

Set up GoToSocial instance

...

Create and setup an account

...

Migrate current account to new GoToSocial instance

...