Error setting up Object Storage on Mastodon
Preface: I installed Mastodon through the app marketplace.
I am following the Linode guide here:
https://www.linode.com/docs/guides/linode-object-storage-with-mastodon/
I inserted the server config block for the proxy domain into my existing site config before the site server config block, as instructed in the article. I made the requisite changes to the domains as stated in the article.
However, when I check the nginx config (which is done by the certbot command in the next step automatically), I get the following error:
Error while running nginx -c /etc/nginx/nginx.conf -t.
nginx: [emerg] "proxy_cache" zone "CACHE" is unknown in /etc/nginx/nginx.conf:61
nginx: configuration file /etc/nginx/nginx.conf test failed
From what I gather from the error and the config, there is no cache zone key named "CACHE" defined anywhere in the server block, or anywhere else in any of the nginx config files. According to the nginx documentation here:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_path
There should be a proxy_cache_path definition, preferably in the outer http block, which specifies the path for the cache and the associated zone key (and cache size). Something like:
proxy_cache_path /path/to/cache/dir keys_zone=CACHE:10m;
It would seem to me that a normal path for the cache dir should be something like /var/cache/nginx.
It also appears that someone else had the same issue a few months ago, as the singular comment on the article posts about the same error.
I found another guide which gave a proxy_cache_path directive that I have tried:
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:100m max_size=1g inactive=24h;
and I can get past this error. In theory it /should/ work fine, but after finishing out the rest of the guide and restarting Mastodon, it still appears to be storing media attachments on the local filesystem, not in the Object Store. This is a new instance, and the Object Store remains empty, but media files are still being stored in public/system, and the image link still points to the base domain, rather than the media domain for the nginx cache. I don't see any errors in the web service logs (docker logs live_web_1) or in journalctl.
Any ideas? It's almost like the Mastodon config changes didn't take. the ~/mastodon/live/.env.production file is definitely changed, and correct as far as what is in the article (and based on what the official Mastodon docs show).
2 Replies
Hmm.. the Mastodon instance is docker-ized, so maybe I need to run docker-compose up -d
to pull the config changes into the images and restart them? Seems the likely case.
Looks like this was the answer, as I think I have gotten everything working. I have added notes to the Mastodon Object Store article which contain all my findings on getting it working.