You run a WordPress blog, but a lot of your readers spend their time on Mastodon, not on your RSS feed. You’d like them to follow your posts right from their timeline, without copying links by hand. This post shows how to put your blog on the Fediverse with the ActivityPub plugin, and how to fix the Nginx and SEO plugin issues that can break it.
What is ActivityPub?
ActivityPub is the open protocol that connects Fediverse platforms like Mastodon. Here’s the short definition from Wikipedia:
ActivityPub is an open, decentralized social networking protocol based on Pump.io’s ActivityPump protocol. It provides a client/server API for creating, updating, and deleting content, as well as a federated server-to-server API for delivering notifications and content.
In plain words, every platform that speaks ActivityPub can talk to every other one. So if your blog speaks it too, a Mastodon user can follow you like any other account. I wanted to see how well that works, so I installed the plugin on this blog.
Install the ActivityPub plugin
Quick way: WP-CLI
If you have shell access and WP-CLI, run this from your WordPress folder:
wp plugin install activitypub --activate
WP-CLI downloads the plugin and turns it on. You should see a success message for both steps.
Manual way: the dashboard
No shell access? Go to Plugins → Add New, search for “ActivityPub”, then click Install and Activate. This is the way to go on shared hosting.
Installing and configuring the plugin is easy. My trouble came from the rest of my setup, which is what the next two sections are about.
Fix Nginx when /author collides with /auth
The ActivityPub plugin serves your profile from your author page, like /author/username/. On my server, Nginx matched /author with the /auth route I use for Keycloak, so every request got redirected to the identity server.
A prefix location like location /auth also matches /author. Adding a trailing slash makes it match only the Keycloak path:
location /auth/ {
proxy_pass http://keycloak-host:8080;
}
Replace keycloak-host:8080 with your own upstream, then test and reload Nginx:
sudo nginx -t && sudo systemctl reload nginx
If you manage Nginx with automation, I walk through a clean setup in my post on deploying Nginx on Ubuntu with Ansible. You can also see how my Nginx and Keycloak configs fit together.
Unhide author archives in your SEO plugin
Many SEO plugins can hide author archive pages, and that hides your Fediverse profile too. Mine was doing exactly that. Once I turned the setting off, the author URL started showing some weird-looking ActivityPub text, which is actually a good sign: it means the protocol data is being served.
To check it from the terminal, ask for the ActivityPub version of your author page:
curl -H "Accept: application/activity+json" https://example.com/author/username/
You should get JSON back, not an HTML page or a redirect.
Find your blog’s Fediverse identity
The plugin builds your Fediverse identity from your username and your domain name, just like a Mastodon handle: @username@yourdomain.com.
To confirm Mastodon can find it, test the WebFinger lookup:
curl "https://example.com/.well-known/webfinger?resource=acct:username@example.com"
If that returns JSON with a link to your author page, you’re done. Search for the handle on any Mastodon instance and hit follow.
My new Fediverse identity is @chokri@kaliex.co, so search for it on Mastodon and follow me 😉
Hope this saves you some time. If you like open, decentralized tools, Matrix for encrypted, open chat is a good next read.
Leave a Reply