简体   繁体   English

AWS使用python flask不断返回502错误的网关错误

[英]aws keep returning 502 bad gateway error using python flask

hi I've been trying for over a month on this.. 嗨,我已经尝试了一个多月。

so, I'm trying to test facebook oauth so have an exact copy of flask oauth login sample code which I put in my ec2 instance bought a domain and registered it on route 53, made an application load balancer and assigned my ec2 in it. 因此,我正在尝试测试facebook oauth,以便拥有我在ec2实例中放入的flask oauth登录示例代码确切副本,该域名购买了一个域并在路由53上注册,从而创建了应用程序负载均衡器并在其中分配了我的ec2。

the port... I'm using flask default(5000) and security group setting has inbound port 5000(and others I've tried so far - made it for testing anyways) opened and all traffic on outbound. 端口...我正在使用flask default(5000),安全组设置已打开入站端口5000(到目前为止,我已经尝试过其他端口-使其仍然可以用于测试),并且all traffic出站。 like this 像这样

health check is working perfectly fine. 健康检查工作正常。 I can see from flask log it's working and returning 200. 我从烧瓶日志中看到它正在工作并返回200。

but when I type in the domain name it's returning 502 bad gateway and I have no clue what's going on... typing in ip address of the ec2 instance works.. on ec2 instance side where I've turned my app on returns code 400 bad request syntax like this - i have no idea why words are cracked tried changing encoding formats and all failed. 但是当我输入域名时,它返回了502错误的网关,我不知道发生了什么...输入ec2实例的ip地址可以正常工作..在ec2实例端,我打开了我的应用后返回了代码400 像这样的错误请求语法-我不知道为什么单词被破解尝试更改编码格式而全部失败。

so... I've checked security ports, have checked route53 if I assigned my instance on A-type record set correctly, ec2 instance itself seems to work fine, health check from target groups goes all fine, and I'm out of ideas on where i've done wrong. 所以...我检查了安全端口,检查了route53,如果我在A型记录集上正确分配了我的实例,ec2实例本身似乎正常工作,来自目标组的运行状况检查一切正常,而我没有了关于我做错了地方的想法。 please help me on this.... 请帮助我。

stuck on one thing for a long time sure is stressful.. :( 卡在一件东西上很长时间肯定很紧张.. :(

EDIT: curl -vvv {domain_name} returns: 编辑:curl -vvv {domain_name}返回:

* Rebuilt URL to: www.*.xyz/
*   Trying 1****...
* TCP_NODELAY set
* Connected to www.*.xyz (*) port 80 (#0)
> GET / HTTP/1.1
> Host: www.*.xyz
> User-Agent: curl/7.53.1
> Accept: */*
>
< HTTP/1.1 502 Bad Gateway
< Server: awselb/2.0
< Date: Wed, 28 Mar 2018 10:43:58 GMT
< Content-Type: text/html
< Content-Length: 138
< Connection: keep-alive
<
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
</body>
</html>
* Connection #0 to host www.*.xyz left intact

EDIT2: the reason for my bad gateway error was due to my target group was using https protocol. EDIT2:我的bad gateway error的原因是由于我的目标组正在使用https协议。 BUT I need this done with https... since oauth(facebook) only works under https.... 但我需要通过https ...完成此操作,因为oauth(facebook)仅在https下工作。

The 502 Bad Gateway error is an HTTP status code that means that ELB received an invalid response from the EC2 Instance. 502 Bad Gateway错误是HTTP状态代码,表示ELB从EC2实例接收到无效响应。

I guess you have selected HTTPS in your target group, create a new target group with HTTP and attach it to the load balancer. 我想您已经在目标组中选择了HTTPS,并使用HTTP创建了一个新的目标组并将其附加到负载均衡器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM