大网数据广告活动
服务器运维问答

AWS Load Balancer Https Listening to EC2 on http

· 52CE 我爱测

I have my website running in an EC2 instance, Apache2 listening on 80. Since, it should be using https, I configured a AWS Load Balancer . Added ACM certificate to the Load Balancer. Added the Load Balancer's dns in Domain's alia…

问题原文

原帖链接 · sowmiyaksr · CC BY-SA 3.0

I have my website running in an EC2 instance, Apache2 listening on 80.

Since, it should be using https, I configured a AWS Load Balancer . Added ACM certificate to the Load Balancer.

Added the Load Balancer's dns in Domain's alias in Route53.

And Load balancer listening to 443 and redirecting to EC2 instance's 80.

Configured EC2 security group to only accept connections from the ELB's security group on port 80.

Now the issue is, when I access my website, it shows content without js and css.

Saying, "This page trying to load scripts from unauthenticated sources".

Those scripts and stylesheets are in the EC2 instance.

What is the right way, to make all scripts, stylesheets, images loaded through https?

已采纳解答

原帖链接 · Mike · CC BY-SA 3.0

This is an app issue not a server issue if you want the ELB to terminate SSL.

It terminated ssl on the ELB and passes back http to the webserver. So your app is seeing normal http traffic. The ELB adds a special header to the traffic to let anything behind it know that the traffic was SSL in case it wants to send back things like return links/js/css/images with https://

It sends the following header back

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto

Your app must be smart enough to say ok the schema is https OR this header is set so its ssl.. if not http.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-02-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。