Make WordPress ActivityPub plugin work with Nginx

WordPress content management system can successfully federate – there is a nice ActivityPub plugin. However, when running WordPress on Nginx server (as HTTP server, not only reverse proxy) there might be an issue – after setting up ActivityPub on auto.coffee I couldn't find @gytis@auto.coffee from my Mastodon instance.

After doing some digging I found out ActivityPub standard requires webfinger end-point under .well-known folder which by proposed default WordPress configuration for Nginx is forbidden.

First I tried to allow access to .well-known but even though JSON API started working, trying to access specific user end-point it kept throwing following error:

{
  "code": "rest_missing_callback_param",
  "message": "Missing parameter(s): resource",
  "data": {
    "status": 400,
    "params": [
      "resource"
    ]
  }
}

While following example of successfully federating WordPress instance it was expected to return something like this:

{
  "subject": "acct:gytis@blog.gyt.is",
  "aliases": [
    "https://blog.gyt.is/author/gytis/"
  ],
  "links": [
    {
      "rel": "self",
      "type": "application/activity+json",
      "href": "https://blog.gyt.is/author/gytis/"
    },
    {
      "rel": "http://webfinger.net/rel/profile-page",
      "type": "text/html",
      "href": "https://blog.gyt.is/author/gytis/"
    }
  ]
}

Actually problem was that URL was not passed to WordPress' index.php – workaround was provided in issue #8 of ActivityPub plugin. Solution is easy as adding extra location directive in Nginx configuration:

location ~* /.well-known {
    try_files $uri $uri/ /index.php?$args;
}

And there it goes – Auto.Coffee is ready to federate :)

Read more #server and #nginx #configuration tips.


My name is Gytis Repečka, I am Solution Architect and data professional. I enjoy using, promoting and contributing to open source software and love communicating about tech to both advanced and non-tech people. Visit Inretio for consulting services. Comment by mentioning me @gytisrepecka@social.gyt.is on Fediverse.