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.

! center

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 statically 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 (the host domain in GoToSocial terms), but all accounts will have stierand.org as their account 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 Docker compose configuration

I run all my self hosted software in Docker containers. Luckily GoToSocial provides a install howto for its Docker containers that I based my setup on. You can find the setup I run at https://github.com/egoexpress/docker-gotosocial. It makes use of the awesome nginx-proxy and the acme-companion sidecar container that in unison act as a reverse proxy and a way to automatically get TLS certificates via Let's Encrypt.

Adapt reverse proxy configuration

As I want to use GoToSocial behind my preferred reverse-proxy setup using nginx I had to make some changes to its configuration in the docker-compose.yml. The reverse proxy guide even has an nginx example, but for my docker-based setup I had to make additional changes. Those are included in the GitHub repo mentioned above.

Nake sure to include - "127.0.0.1:8080:8080" in the ports section of the docker-compose.yml file and make the app trust the reverse proxy by adding an environment variable such as GTS_TRUSTED_PROXIES=172.0.0.0/8. Otherwise the GoToSocial instance will show up as down in the auto-generated nginx configuration and your browser will show a Bad Gateway error when you try to connect to the instance. All other usual nginx-proxy settings like VIRTUAL_HOST and VIRTUAL_PORT (set to 8080) have to be applied as well.

Edit configuration via environment variables

If you want to change configuration parameters of GoToSocial via environment variables, there is a handy way to do so described in the installation instructions. Just prefix the config setting with GTS_, make it uppercase and exchange every dash with an underscore. The configuration parameter db-address, for instance, can then be changed by the environment variable GTS_DB_ADDRESS.

It is recommended to changed the default log level to warn using the environment variable GTS_LOG_LEVEL, otherwise the log output will be very noisy.

Start up the container setup

TODO

Create and setup an account

TODO

Migrate current account to new GoToSocial instance

TODO: add details from https://docs.gotosocial.org/en/latest/user_guide/migration/