簡體   English   中英

Rails s3 bucket SSL

[英]Rails s3 bucket SSL

我的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證書。

您需要在模型中添加它

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

參考: 是否可以將Paperclip配置為生成HTTPS網址?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM