From 8ba2db78d7c2fa0dd82d75bcabb4032c183c86d1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 10 May 2022 15:40:25 -0500 Subject: [PATCH] Mastodon nginx: ActivityPub routing --- installation/mastodon.conf | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/installation/mastodon.conf b/installation/mastodon.conf index 149a9733a..2316e6021 100644 --- a/installation/mastodon.conf +++ b/installation/mastodon.conf @@ -8,6 +8,14 @@ map $http_upgrade $connection_upgrade { '' close; } +# ActivityPub routing. +map $http_accept $activitypub_location { + default /index.html; + "application/activity+json" @proxy; + # Increase `map_hash_bucket_size` to enable this route: + # 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' @proxy; +} + upstream backend { server 127.0.0.1:3000 fail_timeout=0; } @@ -71,13 +79,11 @@ server { try_files /dev/null @proxy; } - # # Mastodon ActivityPub routes. - # # Conditionally send to Mastodon by Accept header. - # if ($http_accept = "application/activity+json" || $http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") { - # location ~ ^/(inbox|outbox|users|@) { - # try_files /dev/null @proxy; - # } - # } + # Mastodon ActivityPub routes. + # Conditionally send to Mastodon by Accept header. + location ~ ^/(inbox|outbox|users|@(.+)) { + try_files $activitypub_location $activitypub_location; + } # Mastodon public files. # https://github.com/mastodon/mastodon/tree/main/public