Mastodon第三方图片不显示解决方法

图片不显示研究了好半天,最终在GitHub上面看到了一个解决方法,这个方法我试了,反正有效就记录一下。

新版本更新以后,采用第三方存储(比如minio、b2等)可能会导致Mastodon跨域不信任,从而阻断图片显示,官方说法好像是为了安全。。。

只需要在nginx当中配置cors就可以解决这个问题。

        # 允许跨域
    location / {  
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
        add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
    
        if ($request_method = 'OPTIONS') {
            return 204;
        }
    } 

然后重启nginx就好了,我自己测试反正是成功了。

就是这样,我折腾了好半天,心累。。。

参考链接

  1. Version 4.1.1 blocks cached images from external sources
  2. https://github.com/mastodon/mastodon/issues/24235#issuecomment-1492833483

阅读量:0