Skip to content

Commit f26980c

Browse files
authored
Add note about rewriting asset urls when migrating FS->remote storage (#1841)
1 parent 69c3b27 commit f26980c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

content/en/admin/optional/object-storage-proxy.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ title: Proxying object storage through nginx
33
description: Serving user-uploaded files in Mastodon from your own domain
44
---
55

6+
## Summary
7+
68
When you are using Mastodon with an object storage provider like Amazon S3, Wasabi, Google Cloud or others, by default the URLs of the files go through the storage providers themselves. This has the following downsides:
79

810
- Bandwidth is usually metered and very expensive
911
- URLs will be broken if you decide to switch providers later
1012

13+
## Proxying
14+
1115
You can choose to serve the files from your own domain, incorporating caching in the process. In Mastodon, access patterns show that new files are often simultaneously accessed by many clients as they appear in new posts via the streaming API or are shared through federation; in contrast, older content is accessed less frequently. Therefore, relying solely on caching won't significantly reduce the bandwidth usage of your proxy from the actual object storage. To address this, we can implement a cache lock mechanism, which ensures that only one proxy request is made at a time.
1216

1317
Here is an example nginx configuration that accomplishes this:
@@ -134,3 +138,6 @@ systemctl reload mastodon-web
134138
**You can now visit your Mastodon in the browser to confirm everything loads correctly**
135139
{{< /hint >}}
136140

141+
## Migration
142+
143+
If you were previously serving files locally and have migrated to a proxying approach, keep in mind that the "old" media URLs are still circulating and your server will continue getting requests for them for some time. You may want to add a `rewrite` or `redirect` rule to the `location ^~ /system/` section in `nginx.conf` which appropriately sends this traffic to the new location.

0 commit comments

Comments
 (0)