gpt4 book ai didi

python - 用于运行 Python Flask 应用程序的 Elastic Beanstalk (AWS) 的 HTTPS。无法获取要解析的 URL

转载 作者:太空宇宙 更新时间:2023-11-03 14:24:53 25 4
gpt4 key购买 nike

我使用 Flask 框架创建了一个小型 Python 站点。我已经使用 Elastic Beanstalk 将它上传到 AWS,并尝试配置环境以确保启用 HTTPS。我以前用 ASP.NET 和 IIS 做过这个,但不是 Python/Apache。 (我对这个“堆栈”很陌生)。如果我访问底层的 elastic beanstalk URL,我可以正常访问该站点(自己尝试)

http://flask-priceline.f8n9uir55a.ap-southeast-2.elasticbeanstalk.com

但是,当我尝试使用 HTTPS 或 HTTP 访问正确的 DNS 时,例如

http://plmonitoring.in-daws.api.net.au/https://plmonitoring.in-daws.api.net.au/

我得到:

无法访问此站点 plmonitoring.in-daws.api.net.au 的服务器 IP 地址无法找到。尝试运行 Windows 网络诊断。DNS_PROBE_FINISHED_NXDOMAIN

这是我所做的。我已经在 AWS 中创建了一个有效证书。我还在 Route 53 中设置了适当的记录集/CNAMES,以便我的别名指向我创建的负载均衡器。

我已经使用经典负载均衡器创建了我的 Elastic Beanstalk 环境。负载均衡器位于公共(public)子网中,运行 Web 服务器的 EC2 实例位于私有(private)子网中。 (这个 VPC 是预先存在的并且配置正确)。我在负载均衡器上创建了以下监听器:

enter image description here

我通过以下 .ebextensions 配置文件完成了此操作:

option_settings:
aws:elb:listener:443:
SSLCertificateId: arn:aws:acm:ap-southeast-2:xxxxxxxxxxxxx:certificate/xxxxxxxxxxxxxxxxxxxx
ListenerProtocol: HTTPS
InstancePort: 80

我还在我的安全组中设置了以下设置(我尝试将 HTTP 80 添加为负载均衡器的入站和 EC2 的出站/EC2 的入站,也没有更改)。这是入站负载均衡器安全组:

enter image description here

负载均衡器输出:

enter image description here

EC2 在:

enter image description here

EC2 输出:

enter image description here

我还将此示例添加到 .ebextensions 文件夹中,希望它能在用户输入 HTTP 而不是 HTTPS 时将 HTTP 重定向到 HTTPS - https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/security-configuration/https-redirect/python/https-redirect-python.config

最佳答案

最糟糕的人为错误。将记录设置为 IPV4,而不是 CNAME!。问题解决了。

关于python - 用于运行 Python Flask 应用程序的 Elastic Beanstalk (AWS) 的 HTTPS。无法获取要解析的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58092523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com