简体   繁体   English

如何在 ec2 实例中使用私有 ip 调用 api

[英]How to call an api using private ip in an ec2-instance

I have deployed an Angular app and a Java REST-API on my ec2-instance.我在我的 ec2 实例上部署了 Angular 应用程序和 Java REST-API。

My angular app is hitting the Java REST-API if I use a public IP, but when I provide a private IP of my instance, it throws an connection time out error. My angular app is hitting the Java REST-API if I use a public IP, but when I provide a private IP of my instance, it throws an connection time out error.

So is there any way I can call my Java REST-API using private IP from within my Angular app.那么有什么方法可以从我的 Angular 应用程序中使用私有 IP 调用我的 Java REST-API。 I have setup a vpc and the instance is lying inside the vpc.我已经设置了一个 vpc,并且该实例位于 vpc 内。

Well as frontend code gets downloaded and runs on the client browser then the request for the backend resource will originate from the client IP and as we all know that we cannot connect to the internet from private IP that is why the request is failing when I try to use private IP.以及前端代码被下载并在客户端浏览器上运行,那么后端资源的请求将来自客户端 IP 并且我们都知道我们无法从私有 IP 连接到互联网,这就是我尝试时请求失败的原因使用私有 IP。

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

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