laravelでサイトを構築しており、下記の問題に数日悩んでいます。
概要
httpsでアクセス時、ajaxで読み込みが起きた時にChromeのコンソールに下記のエラーが出ます。
The page at 'https://some.aaa.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://some.aaa.com/_debugbar/assets/stylesheets?1432136693'. This request has been blocked; the content must be served over HTTPS.
laravel-debugbarを使用しているのですが、下記ページと同様の問題も起きます。
https://github.com/barryvdh/laravel-debugbar/issues/347
ソースを見ると、jsやcssを読み込んでいるリンクは下記になっており、httpやhttpsは指定されていません
<link rel='stylesheet' type='text/css' property='stylesheet' href='//some.aaa.com/_debugbar/assets/stylesheets?v=1484813989'> <script type='text/javascript' src='//some.aaa.com/_debugbar/assets/javascript?v=1483605979'></script><script type="text/javascript">
ajaxは下記のように、http等は指定されていません。
$.ajax({ type: "POST", async: true, url: "/aaa", dataType: "json", success: function (data) { // } });
対策としては下記を行いました。
生成するURLがhttpになる問題があったのですが、下記2点で解決しました。
・TrustedProxyを追加
https://github.com/fideloper/TrustedProxy
・"\URL::forceSchema('https');"追加
https://teratail.com/questions/58148
しかし、それでも"was loaded over HTTPS"の問題だけ解決しません。
サーバ構成
ELB:80 -> EC2:80
ELB:443 -> EC2:80
httpでアクセスされた場合はEC2のapache2.4でhttpsにリダイレクトさせています。
ApacheのVirtualHostはこのようにしています。
<VirtualHost *:80> ServerName dev.example.com:80 RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Port} !^443$ RewriteCond %{HTTP_USER_AGENT} !^ELB-HealthChecker RewriteCond %{REQUEST_URI} !=/server-status RewriteCond %{HTTP:X-FORWARDED-FOR} !^$ RewriteRule ^(.*)?$ https://%{HTTP_HOST}$1 [R=301,L] DocumentRoot "/home/example" <Directory "/home/example"> Options FollowSymLinks ExecCGI AllowOverride all Require all granted </Directory> </VirtualHost>
ちなみに、EC2にも証明書を設定して、
ELB:443 -> EC2:443
にすると問題ありません。
どうそよろしくお願いします。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/06/07 11:45 編集
2017/06/08 09:26
退会済みユーザー
2018/01/24 07:52