ec2 没有使用 AWS beanstalk 响应 443

Posted

技术标签:

【中文标题】ec2 没有使用 AWS beanstalk 响应 443【英文标题】:ec2 isn't responding on 443 with AWS beanstalk 【发布时间】:2014-12-25 18:55:07 【问题描述】:

我在 AWS 中使用弹性 beanstalk。我有一个试图部署到 https 的 java/tomcat 应用程序。我现在花了将近 2 天的时间来尝试启动和运行 https,但成功率很低。我所做的和我所看到的正在发生。

1. I bought and created a ssl certificate that I installed with my load balancer.
2. I pointed 443 in load balancer security to 80 as the instructions stated and I've also tried pointing it to 443,8443,4443
3. In my security group for my beanstalk instance, I enabled 443 to all external ips
4. In beanstalk I turned on port 443

现在我真的很困惑。

1. As long as I don't try and secure my entire application, I'm able to get ssl working in my apps admin accounts without issue. The app will automatically redirect the protocol from http to https. 
2. Oddly enough I'm outputting the active port and no matter if I'm in http or https, the app is seeing the active port as 8080. How could this be if the load balancer is suppose to be using 443? Also, how would the ssl certificate work on port 8080 or is the ssl certificate working somehow on the load balancer side and the load balancer is doing some sort of port forwarding to the ec2 instance?
3. If I attempt to secure the entire application doing a forced redirect to https from http. The app fails to load. I've tried redirecting to 443,8443,4443 without success. I need to do this redirect in order to tell google my pages have moved from 80 to 443.

有人了解我正在发生的事情或它是如何工作的吗?

【问题讨论】:

【参考方案1】:

在您的应用程序环境中单击>> 配置,然后滚动到网络层并编辑负载平衡属性。

为安全侦听器端口选择 443,为协议选择 HTTPS,最后选择您之前在负载均衡器中添加的证书。

为了回答您的问题,您的 SSL 证书安装在负载平衡器上,该端口将服务器上的所有流量从 443 转发到 8080。在您的应用程序上强制使用 443 会破坏您的应用程序,因为 Elastic Beanstalk 负载均衡器将转发到端口 8080,而不是我怀疑您的应用程序正在侦听的 443 端口。

【讨论】:

谢谢,你是绝对正确的。在实现负载均衡器将所有请求转发到 8080 而不是基于 URL 协议的端口后,我昨晚能够解决我的问题。 AWS 需要更好地记录该行为。可能是一个不同的问题,但我不知道该应用程序应该如何区分页面是否应该是安全的。例如,页面 a,具有一些链接的非安全页面,其中一个链接指向安全页面。在渲染页面 a 时,如果一切都在 http 端口 8080 上完成,它如何知道指向安全页面?

以上是关于ec2 没有使用 AWS beanstalk 响应 443的主要内容,如果未能解决你的问题,请参考以下文章

使用 Elastic Beanstalk 创建时的 AWS EC2 .pem 证书

使用 AWS EC2 或 Beanstalk 删除 Laravel 5 中的公用文件夹

从 AWS Beanstalk 应用程序连接到 AWS EC2

AWS - 配置从 Beanstalk 应用程序对 EC2 实例的访问

使用 AWS Elastic Beanstalk 将多个应用程序部署到单个 EC2 实例

AWS:使用 Elastic Beanstalk 命令行界面 (EB CLI) 3.x SSH 到 EC2