Rails s3 bucket SSL

 蜡笔小新11953150 发布于 2023-02-02 19:58

我的rails 4应用程序正在使用Amazon s3存储桶来存储图像.配置非常默认,我的production.rb文件看起来像这样

config.paperclip_defaults = {
  :storage => :s3,
  :s3_credentials => {
    :bucket => ENV['S3_BUCKET_NAME'],
    :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
  }
}

当页面加载图像时,它会像这样加载它:

http://s3.amazonaws.com/themoderntrunk/designs/photos/000/000/052/large_thumbnail/product12.jpeg?1389721666

我希望它加载前缀https:

https://s3.amazonaws.com/themoderntrunk/designs/photos/000/000/052/large_thumbnail/product12.jpeg?1389721666    

没有SSL,我的应用程序在控制台中收到警告

he page at 'https://www.themoderntrunk.com/assortments/4/designs/52-product-12' was loaded over HTTPS, but displayed insecure content from 'http://s3.amazonaws.com/themoderntrunk/designs/photos/000/000/049/grid/product9.jpg?1389721643': this content should also be loaded over HTTPS.

当然,在我的production.rb文件中config.forse_ssl = true.我的应用程序也有SSL证书.

1 个回答
  • 您需要在模型中添加它

    class Designs < ActiveRecord::Base
      has_attached_file :photo, :s3_protocol => :https
    

    参考:是否可以配置Paperclip来生成HTTPS URL?

    2023-02-02 20:01 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有