Skip to content

missing hint on considering redirection after moving media e.g. to S3 storage #1627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
soletan opened this issue Apr 2, 2025 · 0 comments

Comments

@soletan
Copy link
Contributor

soletan commented Apr 2, 2025

After following your documentation at

https://docs.joinmastodon.org/admin/optional/object-storage/

and

https://docs.joinmastodon.org/admin/optional/object-storage-proxy/

as part of maintaining an existing instance, we've missed to add a redirection from old URLs of media to new URLs which lead to multiple issues with federated instances failing to fetch images deployed prior to the move. As we have seen similar issues in opposite direction we might not have been the only ones who failed to consider that. Thus, I'd prefer having a proper remark on either page on how to fix the nginx configuration so that media queries are forwarded to the new URL.

In /etc/nginx/sites-enabled/mastodon-ssl, we have changed the location section for ^/system/ from

location ~ ^/system/ {
  add_header Cache-Control "public, max-age=2419200, immutable";
  add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
  add_header X-Content-Type-Options nosniff;
  add_header Content-Security-Policy "default-src 'none'; form-action 'none'";
  try_files $uri =404;
}

to

location ~ ^/system/ {
  rewrite ^/system/(.*)$ https://name.of.our.s3-proxy.host/$1 permanent;
}

This might not be the best solution with regard to common remarks on preventing use of rewrite in nginx, but it works as a quick solution.

@andypiper andypiper transferred this issue from mastodon/joinmastodon Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant