The potential demise of Twitter has lead to many users, myself included, moving across to Mastodon, a tool for participating in the free and open source distributed social network called the Fediverse. As well as joining a third-party server, users also have the option of running their own instance. Over the past few weeks this is the project that has consumed me.
Firstly, it is important to realise that Mastodon is not the only option for participating in the network. Any tool that can handle the ActivityPub protocol can participate and share content across the Fediverse.
While Mastodon, like Twitter, specialises in microblogging, others may be more focused on images or as a Facebook replacement. Mastodon itself is a bit of a beast to setup and demanding on server resources. Others have more modest requirements or are written in different programming languages. I will detail a few tools I looked at below.
WordPress ActivityPub Plugin
Matthias Pfefferle’s ActivityPub plugin for WordPress is still in beta, but I managed to get it successfully sharing my blog posts to the Fediverse. The plugin uses your WordPress profile and domain for the profile and has a number of options for how your content will be shared.
The plugin makes it easy to share content from WordPress and receive comments (I have not tested this), but what it lacks is a way of viewing streams of other users’ posts, so it’s more of an adjunct tool.
Microblog.pub
microblog.pub is a wonderfully minimalist implementation of a personal ActivityPub service. The resource requirements are very low and the basic design reminiscent of the original days of the Web. If you just want a simple microblog feed on your website and the ability to contribute to the greater Fediverse then it’s a good choice. But it’s not compatible with other clients for posting on your phone or other device so you are stuck using the web browser.
Mastodon
Mastodon is the tool that everyone is talking about, so I figured that I’d better get familiar with it. I actually attempted to set Mastodon up four times and I’ll share a few tips here.
Initially I tried the Mastodon droplet at DigitalOcean, as mentioned in the official Mastodon setup docs. I got it working, sort of, occasionally, but then had problems updating. So I canned that.
I then tried the Docker route Linode. I’ve only just started learning Docker and I had issues getting this to run.
Following the recommendations of someone else who had recently setup a Mastodon instance I decided to go down the source install route.
Mastodon makes pretty hefty demands on the server so I chose a dedicated 2CPU/4GB system located “locally” in Sydney with Linode. I also setup a Google Cloud storage bucket as I already had a Google Cloud account and chose Mailjet as my SMTP mailer. I initially installed Ubuntu 20.04 LTS, but then decided to upgrade it to Ubuntu 22.04 LTS, which went pretty smoothly.
I basically followed the official Mastodon instructions for:
For the Google side I also looked at Justin Ribeiro’s instructions.
DNS
Configure your domains first and allow time for the changes to propagate. For the first instance I let Linode manage my domain, but with the second it was a subdomain of an existing domain managed elsewhere, so I just pointed the subdomain to the server. You can modify the .env.production settings for that your username will show up as @user@example.com even if the url of the site is sub.example.com.
LOCAL_DOMAIN=example.com
WEB_DOMAIN=sub.example.com
If you do this then you need to add either a proxy redirect or (because I don’t have access to the web server’s configuration) a redirect in the .htaccess file of the web application at example.com .
Redirect 301 /.well-known/webfinger https://sub.example.com/.well-known/webfinger
You should setup Mailjet (or your own SMTP relay) before configuring Mastodon. You need access to the DNS settings to add TXT entries for
For Mailjet your SMTP username and password credentials are your API key and secret. Don’t forget to keep them when setting up your account!
Certificates
The instructions for setting up NGINX and acquiring an SSL certificate didn’t work for me. Instead I had to generate an SSL certificate with
systemctl stop nginx
certbot certonly --standalone -d
systemctl start nginx
I then had to manually uncomment the SSL certificate lines in /etc/nginx/sites-available/mastodon.
Repeat if you are setting up a proxy for cloud storage.
Storage
I setup a nginx proxy alias for the cloud storage. I found that I had to make the cloud storage bucket publicly readable to the internet in order for this to work. I’m not 100% this is a good idea, although nothing secret should be stored in there as part of the Mastodon process.
The relevant .env.production storage settings were (HIDDEN and files.example.com should be replaced by the appropriate values):
S3_ENABLED=true
S3_PROTOCOL=https
S3_HOSTNAME=storage.googleapis.com
S3_ENDPOINT=https://storage.googleapis.com
S3_MULTIPART_THRESHOLD=52428800
S3_BUCKET=google-bucket-name
S3_REGION=australia-southeast1
AWS_ACCESS_KEY_ID=HIDDEN
AWS_SECRET_ACCESS_KEY=HIDDEN
S3_ALIAS_HOST=files.example.com
In the second instance I used local static storage as it is only for personal posting.
When I started it up I found that static files were unable to be loaded as the nginx user lacked permissions on the files. The solution was:
sudo chmod +x /home/mastodon
Database
My only advice here is don’t type KB instead of kB in postgresql.conf, okay?
Appearance
Some CSS I added under admin/settings/appearance to make one of the instances (a karate community) a bit different from the others.
body { background-color: #f0f0f0; }
a .active { color: #336699; }
.reply-indicator__content a, .status__content a {
color: #336699; !important }
.column-link--transparent.active {
color: #336699;
}
.button { background-color: #336699; }
.search__input{ background-color: #e3e3e3; }
.logo { filter: invert(37%) sepia(70%) saturate(484%) hue-rotate(169deg) brightness(82%) contrast(88%); }
.compose-form .autosuggest-textarea__suggestions, .compose-form .compose-form__buttons-wrapper {
background-color: #c3c3c3; !important
}
Where to from here?
I’ve spent more time setting up and configuring Mastodon and other instances than I have actually posting. I want to further test the WordPress ActivityPub plugin and understand how I can directly code for ActivityPub, especially if there’s something that can be done with microcontrollers.
If you want to follow me I’m at @allrite@allrite.at on Mastodon.