迁移到 s3 后系统头像丢失

几周前,我们将存储从本地迁移到了 S3。帖子和用户头像已成功迁移,但自定义系统头像除外。

看起来 URL 重写失败了,因为 S3_CDN_URL 被附加到了论坛 URL 之后。

我尚未检查数据库,但似乎"https:{S3_URL}"是头像的相对全局 URL?

https://forum.tosdr.org/https://tosdr-forum.s3.eu-west-2.jbcdn.net/original/1X/3662711e5030823983d25ac319ce6b9a7ad030e6.png

请注意,此问题仅出现在系统头像上,该文件在 S3 上也存在,只是相对 URL 出现了错误。

更换头像也无法解决。Gravatar 会出现同样的问题,字母图片也是如此。

有什么解决方案吗?注意:我们已将论坛重新安装到较旧的备份,并再次迁移了站点。

我检查了数据库,所有上传都完全正常。(问题中的头像上传是有效的)

会不会是这一行导致的?

不过 s3_cdn_url 确实存在,我实在想不出其他解释。

即使返回 200 OK,头像似乎也没有更新。

Started PUT "/u/system/preferences/avatar/pick" for 87.78.131.160 at 2021-04-10 12:55:46 +0000
Processing by UsersController#pick_avatar as */*
  Parameters: {"upload_id"=>"", "type"=>"system", "username"=>"system"}
Completed 200 OK in 15ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 4976)
Started PUT "/u/system/preferences/avatar/pick" for 87.78.131.160 at 2021-04-10 12:55:02 +0000
Processing by UsersController#pick_avatar as */*
  Parameters: {"upload_id"=>"1", "type"=>"gravatar", "username"=>"system"}
Completed 200 OK in 15ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 5061)
Started PUT "/u/system/preferences/avatar/pick" for 87.78.131.160 at 2021-04-10 12:54:13 +0000
Processing by UsersController#pick_avatar as */*
  Parameters: {"upload_id"=>"695", "type"=>"uploaded", "username"=>"system"}
Completed 200 OK in 17ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 4982)

以上所有请求都导致查询了无效的基 URL:

Started GET "/u/system/preferences/https://tosdr-forum.s3.eu-west-2.jbcdn.net/original/1X/3662711e5030823983d25ac319ce6b9a7ad030e6.png" for 87.78.131.160 at 2021-04-10 12:54:15 +0000
Processing by UserBadgesController#username as JSON
  Parameters: {"username"=>"system"}
ActionController::RoutingError (No route matches [GET] "/u/system/preferences/https:/tosdr-forum.s3.eu-west-2.jbcdn.net/original/1X/3662711e5030823983d25ac319ce6b9a7ad030e6.png")
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:177:in `call'
  Rendering exceptions/not_found.html.erb within layouts/no_ember
  Rendered exceptions/not_found.html.erb within layouts/no_ember (Duration: 0.3ms | Allocations: 105)
  Rendered layouts/_head.html.erb (Duration: 1.2ms | Allocations: 262)
  Rendered common/_discourse_stylesheet.html.erb (Duration: 3.5ms | Allocations: 1094)
Completed 200 OK in 19ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 4961)