Make your Mastodon account discoverable on your Ghost domain

Use your own hostname as an alias to your Mastodon account.

Make your Mastodon account discoverable on your Ghost domain
Mastodon is a free, open-source project for running social networks.

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:

  1. Log into the server where you are running Ghost.
  2. Confirm that Nginx is set up to serve files from the /.well-known URL path:
    1. cd /etc/nginx/sites-available
    2. less example.com-ssl.conf where "example.com" is your site's hostname
    3. Verify that the config file contains location - /.well-known { ... }
    4. Note the file location next to root for the next step
    5. Hit q to get back to the shell
  3. Create the .well-known directory by running sudo mkdir /var/www/example_com/system/nginx-root/.well-known where the path is the root location from your Nginx config plus .well-known.
  4. 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.
  5. Move the file to the .well-known directory: sudo mv /tmp/webfinger /var/www/example_com/system/nginx-root/.well-known,
  6. Verify that your host is returning the WebFinger file by opening https://example.com/.well-known/webfinger in a browser.
  7. 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.