Running the ActivityPub plugin for WordPress requires particular URLs to be working as expected. This is even more true for a multisite instance in a sub-directory. If you’re running a multisite in sub-directories as I do with nginx, it requires some special treatment.

Here at Epiphyt, I have two ActivityPub blog accounts enabled (feel free to follow ❤️). One via @epiphyt@epiph.yt for German and the other via @epiphyt_en@epiph.yt for English. As you can already see, both accounts point to the same domain, as Fediverse accounts don’t know the principle of sub-directories for account names.

When visiting an account, the request is exactly in reverse: https://epiph.yt/@epiphyt and https://epiph.yt/@epiphyt_en

However, while this is working for the first case, the second account wouldn’t be found, as it’s not part of the WordPress blog at https://epiph.yt/ but part of the WordPress blog at https://epiph.yt/en/. So, we first need to redirect the second request:

location ~ ^/\@epiphyt_en {
	return 301 $scheme://$server_name/en/@epiphyt_en;
}Code language: Nginx (nginx)

While you now might see the account of the second blog while searching for it, it doesn’t work properly. This is because of requests being sent to the path /.well-known/webfinger need to be working properly as well (that is true for both accounts). They first need to point to the WordPress installation itself:

location ~ ^/.well-known/webfinger {
	try_files $uri $uri/ /index.php?$uri&$args;
	include /etc/nginx/proxy_params;
}Code language: Nginx (nginx)

Now the account @epiphyt@epiph.yt is working just fine, the account @epiphyt_en@epiph.yt however still does not. This is because – again – the URL needs to be redirected. Since such requests always contain a resource URL parameter, we can redirect only requests for this account, which is done by checking for the URL parameter resource=acct:epiphyt_en@epiph.yt:

location ~ ^/.well-known/webfinger {
	if ( $query_string = "resource=acct:epiphyt_en@epiph.yt" ) {
		return 301 $scheme://$server_name/en/.well-known/webfinger?resource=acct:epiphyt_en@epiph.yt;
	}

	try_files $uri $uri/ /index.php?$uri&$args;
	include /etc/nginx/proxy_params;
}Code language: Nginx (nginx)

Make sure you adjust the account names according to your needs and reload the nginx configuration afterwards before testing.

Reposts

Leave a Reply

Your email address will not be published. Required fields are marked *