Make your Mastodon account discoverable on your Ghost domain
If you're heading to the Fediverse, you might be wondering, "With all of the ActivityPub servers out there, how do I ensure that people can find me? What if I move servers? Can I use my own domain as an address without standing up a Mastodon instance?" The answer is yes you can, thanks to a protocol called WebFinger. Maarten Balliauw published a blog post that explains how this works, and I recommend reading his detailed explanation. In brief, you need to put a file on your web server under the /.well-known/webfinger path that contains the location of your Mastodon server and your account name.
I use Ghost for my blog, I thought it would be useful to show you how to add this file to a self-hosted Ghost instance:
- Log into the server where you are running Ghost.
- Confirm that Nginx is set up to serve files from the
/.well-known
URL path:cd /etc/nginx/sites-available
less example.com-ssl.conf
where "example.com" is your site's hostname- Verify that the config file contains
location - /.well-known { ... }
- Note the file location next to
root
for the next step - Hit
q
to get back to the shell
- Create the
.well-known
directory by runningsudo mkdir /var/www/example_com/system/nginx-root/.well-known
where the path is the root location from your Nginx config plus.well-known
. - Download the WebFinger file for your account on your favorite Mastodon server by running
curl -v 'https://mastodon.social/.well-known/webfinger?resource=acct:yourname@mastodon.social' > /tmp/webfinger
, replacing "yourname" with your username on the Mastodon server and "mastodon.social" with the hostname of your Mastodon server. - Move the file to the
.well-known
directory:sudo mv /tmp/webfinger /var/www/example_com/system/nginx-root/.well-known
, - Verify that your host is returning the WebFinger file by opening
https://example.com/.well-known/webfinger
in a browser. - Head to a Mastodon server and search for your account name, but using the hostname of your Ghost blog, e.g. "@yourname@example.com". You should see the account from the Mastodon server got the WebFinger file from.
Now you can move freely through the Fediverse without constantly updating your account name every time you change servers. Find me, now and forever, at @paul@obscure.com.