简体   繁体   English

前端和后端服务器(托管在单独的AWS实例上)无法通信

[英]Frontend and backend servers (hosted on separate aws instances) can't communicate

My two ec2 instances are on the same subnet and I have configured the security group such that they can communicate with each other (pinging each others private ip adresses and connecting via telnet). 我的两个ec2实例位于同一子网上,并且我已经配置了安全组,以使它们可以彼此通信(彼此ping私有IP地址并通过telnet连接)。

The frontend instance is hosting an angular app on nginx, the backend instance is hosting a spring boot app. 前端实例在nginx上托管有角度的应用程序,后端实例在托管spring boot应用程序。 The angular app makes http requests to the spring boot app and shows the results. angular应用程序向spring boot应用程序发出http请求,并显示结果。 Pretty simple stuff. 很简单的东西。 Now when I made the http requests to go to the public ip address of the backend instance everything worked great. 现在,当我发出http请求以转到后端实例的公共ip地址时,一切正常。 When I changed them to go to the private ip address it stopped working and I'm getting request timeouts. 当我将它们更改为私有IP地址时,它停止工作,并且出现请求超时。 Why is this happening? 为什么会这样呢? I can clearly access the private ip address via telnet but angular cannot. 我可以通过telnet清楚地访问私有IP地址,但是angular不能。

Your Angular application runs on client's browser. 您的Angular应用程序在客户端的浏览器上运行。 Request to backend app is made from the client's browser which cannot access the backend instance by Private IP. 从客户端的浏览器发出对后端应用程序的请求,该浏览器无法通过私有IP访问后端实例。

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

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