简体   繁体   English

AWS上的502网关错误-API

[英]502 Gateway Error on AWS - API

I am creating a test web app and have deployed it to AWS Ubuntu server using nginx.. 我正在创建一个测试Web应用程序,并已使用nginx将其部署到AWS Ubuntu服务器。

I am getting a 502 Bad Gateway error when it tries to reach my API.. 尝试访问我的API时,我收到502错误网关错误。

I am new to this and have started node.js and all seems to working fine except when I want to perform an API call to mongodb to read or write information. 我对此并不陌生,并且已经启动了node.js,并且除我要对mongodb进行API调用以读取或写入信息外,其他一切似乎都工作正常。 it is working fine locally so I am at a loss.... 它在本地工作正常,所以我很茫然。

GET http://ec2-54-72-145-112.eu-west-1.compute.amazonaws.com/api/rest/golf 502 (Bad Gateway) GET http://ec2-54-72-145-112.eu-west-1.compute.amazonaws.com/api/rest/golf 502(Bad Gateway)

this is nginx server config 这是nginx服务器配置

 location /xxxxxxxxxxxxxxx{ 
 alias /home/ubuntu/xxxxxxxxxxxxxx/site/public; 
 } 

 location /api/ { 
 proxy_pass http://127.0.x.1:8180/api/; 
 } 

.. ..

I know I may not be giving enough info but hopefully someone has an idea.. 我知道我可能没有提供足够的信息,但希望有人有一个主意。

Thanks! 谢谢!

The nginx error message HTTP 502 indicates the nginx is working fine but cannot reach your specified proxy. nginx错误消息HTTP 502指示nginx正常运行,但无法访问您指定的代理。 So I'd suggest you to check whether the port and binding IP are correct. 因此,建议您检查端口和绑定IP是否正确。

You can check which ports are bound by which application using this command on your Ubuntu machine: 您可以在Ubuntu计算机上使用以下命令检查哪些端口受哪个应用程序绑定:

netstat -tulpen

You should see a line with the column "Local Address" and in your case the value 127.0.x.1:8180 . 您应该在“本地地址”列中看到一行,在您的情况下,值为127.0.x.1:8180 If it's not there try to figure out which port is bound by your node application and reconfigure the nginx to use that port. 如果不存在,请尝试找出您的节点应用程序绑定了哪个端口,然后重新配置nginx以使用该端口。

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

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