From 2a389ab2252a8a98918025a1c8abc65a3c31b75e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 11 May 2022 17:55:12 -0500 Subject: [PATCH] Mastodon nginx: simplify static files --- installation/mastodon.conf | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/installation/mastodon.conf b/installation/mastodon.conf index c932239e2..7d1181dc2 100644 --- a/installation/mastodon.conf +++ b/installation/mastodon.conf @@ -73,7 +73,7 @@ server { # Fallback route. # Everything not routed should fall back to the SPA. location / { - try_files /index.html /dev/null; + try_files /dev/null @static-files; } # Mastodon backend routes. @@ -88,21 +88,12 @@ server { try_files $activitypub_location $activitypub_location; } - # Mastodon public files. - # https://github.com/mastodon/mastodon/tree/main/public - # Take only what we need for Soapbox. - location ~ ^/(assets|favicon.(ico|png)|browserconfig.xml|embed.js|android-chrome-192x192.png|apple-touch-icon.png|(avatars|headers)/original/missing.png) { - root /home/mastodon/live/public; - add_header Cache-Control "public, max-age=31536000, immutable"; - add_header Strict-Transport-Security "max-age=31536000" always; - } - # Soapbox & Mastodon (frontend) build files. # New builds produce hashed filenames, so these should be cached heavily. location /packs { add_header Cache-Control "public, max-age=31536000, immutable"; add_header Strict-Transport-Security "max-age=31536000" always; - try_files $uri @mastodon-public; + try_files /dev/null @static-files; } # Soapbox configuration files. @@ -124,6 +115,12 @@ server { try_files $uri /index.html; } + # Soapbox & Mastodon static files. + # Try Soapbox first, Mastodon, then fall back to the SPA. + location @static-files { + try_files $uri @mastodon-public; + } + # Proxy to Mastodon's Ruby on Rails backend. location @proxy { proxy_set_header Host $host;