python - 使用 https 时从公共 IP 拒绝 AWS 连接
问题描述
我有一个 python-flask Web 应用程序在 AWS EC2 实例上的 docker 中运行。我正在使用 python-sslify 强制使用 https,但我收到“连接被拒绝”。我确保在安全组的入站规则中打开了 80 端口,并打开了 443 端口。如果我关闭 sslify,一切运行正常,只是不安全。使用 sslify 我得到以下信息:
$ curl https://localhost
curl: (35) gnutls_handshake() failed: The TLS connection was non-properly terminated.
$ curl https://ec2-**-**-***-***.compute-1.amazonaws.com/login
curl: (7) Failed to connect to ec2-**-**-***-***.compute-1.amazonaws.com port 443: Connection refused
据我所知,gnutls_handshake 错误是旧版本 curl 的问题,所以我得出的结论是它工作正常,只是没有对互联网开放。查看服务器的调试输出,我可以看到一个连接进来,接收到 302 重定向到 https,但就是这样。端口 80 肯定是开放的并且工作正常,端口 443 不是,我不知道为什么。除了安全组的入站规则之外,我还需要在其他地方打开端口 443 吗?
这是入站规则,顺便说一句。此外,服务器在 docker 中的 0.0.0.0:8000 上运行,端口 80、443 和 8000 已暴露。
编辑:请求 telnet 443:
$ telnet localhost 443
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
$ telnet ec2-**-**-***-***.compute-1.amazonaws.com 443
Trying **-**-***-***...
telnet: Unable to connect to remote host: Connection refused
编辑 2:Netstat 测试:
$ netstat -a -n -t | grep ':443.*LISTEN'
tcp6 0 0 :::443 :::* LISTEN
解决方案
推荐阅读
- python-3.x - 从 stats.wilcoxon 获取 z 统计量
- api - 无法在前端 .html 中显示全局变量
- ios - 考虑到变异和关系,我如何拥有基于协议的数据模型?
- async-await - NestJS 如何使用异步中间件?
- javascript - 有没有办法以编程方式从 G.Drive 下载压缩文件?
- excel - 从电子邮件中检索特定文本
- h2o - h2o gridsearch“TypeError:不支持的操作数”错误
- ruby-on-rails - 全球化和行动文本
- python - 在模型上的 save() 覆盖期间查询中没有匹配的对象 - 抛出 DoesNotExist 错误
- azure - 如何使用 azure AzAnalysisServicesServer powershell 获取分析服务的定价层