在一个 EC2 实例前面引入 ALB(AWS 上的应用程序负载均衡器)后,Chrome 浏览器显示 Mixed Content Error。(出于安全原因,我稍微编辑了错误的内容)
Mixed Content: The page at 'https://www.sample.com/talk' was loaded
over HTTPS, but requested an insecure EventSource endpoint
'http://www.sample.com/api/getData?param1=123¶m2=456'. This
request has been blocked; the content must be served over HTTPS.
模式 1 没有错误。
Pattern2 显示上述错误。我不知道我的技术栈哪里出了问题。
Pattern1: ALB(443) => EC2(443)
Pattern2: ALB(443) => EC2(80)
我的技术栈:
ALB
Apache 2.4
Laravel 5.7
React 16.9
我尝试了以下解决方案,但错误仍然发生。
- Laravel 的信任代理。
- 从 React 到服务器的 HTTP 请求写成相对路径(/api/getData?param1=123¶m2=456),所以我将代码替换为指定协议和域名的绝对路径(https://www.sample.com/api~) .
- 在 Apache Web 服务器中,将 http 重写为 https(我认为这是个坏主意)。
这是普遍问题吗?
如果您有任何提示,请帮助我。
我很抱歉我的英语不好。