###前提・実現したいこと
現在Ruby on Railsで作成したアプリケーションのSSL化を行っているのですが、httpでアクセスした歳には読み込まれるcssとjavascriptが、httpsでアクセスしたとたん、読み込まれなくなり、途方にくれています。
環境は
- Rails 4.2 (Ruby 2.2.1)
- AWS (Linux)
- nginx (1.10.1)
- (ssl証明はletsencryptで)
- ブラウザがchromeでもsafariでも同様の問題が起こる
です。
###発生している問題・エラーメッセージ
html要素は表示されますが、スタイリングがされていないと言う状態です。
chromeのコンソールには、
Mixed Content: The page at 'https://mysite----.jp/' was loaded over HTTPS, but requested an insecure stylesheet 'http://mysite-----.jp/assets/application-f7csdfafdasf9b59e6fd6cc19a9f7b8b0ca4c044e23ce50c9b39893d44.css'. This request has been blocked; the content must be served over HTTPS.``` といったメッセージが複数のcss、javascript、imageに関して表示されています。 これらのURLがhttpsでないことからこのような警告が出ているのだとは理解できましたが、それからどうしたらよいかが分かりません。 ###試したこと * grep "http://" で直書きされている(シェアURLなど)サイト内のすべてのURLを"https"に変更しました。 * [ The Definitive Guide on HowTo Setup and use SSL in Rails 4](http://www.sslendpoint.com/definitive-guide-to-on-how-to-setup-rails-4-and-heroku-ssl-setup.html) を読みました。"If you're exclusively using the Rails Asset Pipeline and serving your static assets directly from your app server everything should just work as, by default, static files are referenced relatively and served from the public/assets directory in production."とあり、私はすべてのimageに関してimage_tag、link_tagを使っていますので、何故うまくいかないのか不思議です。 * [Rails with nginx not serving CSS or JS with HTTPS](http://stackoverflow.com/questions/33671061/rails-with-nginx-not-serving-css-or-js-with-https) を参考に、```config.action_controller.asset_host = "mysite.jp"``` を追加しました。 * 全ての変更のあとに、railsのassets:precompile、nginxのreloadとrestart、rails再起動を行って確認しています。
回答3件
あなたの回答
tips
プレビュー