Thibaud Clement
Thibaud Clement

Reputation: 6897

Rails 4 x AWS S3: "This content should also be served over HTTPS."

In my Rails 4 app, I use the paperclip gem to allow users to upload images.

The images are stored on AWS S3.

Here is my configuration in config/environments/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']
  }
}

This was working perfectly fine before I implemented an SSL certificate.

Now that my app — in production — is set with HTTPS, I get the following error in the console:

Mixed Content: The page at 'https://www.domain.com/' was loaded over HTTPS, but requested an insecure image 'http://s3.amazonaws.com/app/model/images/000/000/003/small_thumb/Profile_Picture.png?1448899439'. This content should also be served over HTTPS.

This does not "break" the app, but I would like to make things run properly.

How can I fix this?

Upvotes: 2

Views: 481

Answers (1)

infused
infused

Reputation: 24337

Tell Paperclip to produce HTTPS URLs by adding this option to your Paperclip options hash:

:s3_protocol => :https

Upvotes: 2

Related Questions