[英]How to connect a webpage behind a AWS EC2 instance in a private subnet in a AWS VPC
I have a AWS VPC with 1 Public and 1 Private Subnets.我有一个带有 1 个公共子网和 1 个私有子网的 AWS VPC。 I have put 1 EC2 instances in each of the subnets.
我在每个子网中放置了 1 个 EC2 实例。 Both the EC2 instances have Apache http server running in port 80 and have a HTML page.
两个 EC2 实例都有 Apache http 服务器在端口 80 中运行,并有一个 HTML 页面。 Say, there in Page1.html in the Public EC2 instance and Page2.html in the Private EC2 instance.
比如说,在公共 EC2 实例中的 Page1.html 和私有 EC2 实例中的 Page2.html 中。 Page1.html in Public EC2 instance has a URL that points to Page2.html in Private EC2 instance.
公共 EC2 实例中的 Page1.html 有一个 URL 指向私有 EC2 实例中的 Page2.html。
All the Security Groups are open to all traffic and the NAT Gateway is allocated with a Elastic IP.所有安全组都对所有流量开放,并且 NAT 网关分配有弹性 IP。
When I put (http:// public IP address:80/Page1.html) in browser I get the Page1.html displayed.当我在浏览器中输入(http://public IP 地址:80/Page1.html)时,会显示 Page1.html。 But when I click the link on Page1.html which points to Page2.html in Private EC2 instance, the Page2.html is not displayed.
但是,当我单击指向私有 EC2 实例中的 Page2.html 的 Page1.html 上的链接时,不会显示 Page2.html。 The request eventually times out.
请求最终超时。
Is there a way I can make these 2 Apache servers talking to each other?有没有办法让这 2 个 Apache 服务器相互通信?
It may worth noting that:可能值得注意的是:
i) I can ping the (private ip) from the public instance. i)我可以从公共实例ping (私有IP) 。
ii) From the public instance, I can run " nc -vz (private ip) 80 " and get response as " Connection to (private ip) 80 port [tcp/http] succeeded! " ii) 从公共实例中,我可以运行“ nc -vz (private ip) 80 ”并得到响应为“ Connection to (private ip) 80 port [tcp/http] succeeded! ”
iii) From the public instance, executing " curl (private ip) 80 " command fetches the HTML script / dump but shows an error " curl: (7) Couldn't connect to server " also. iii) 从公共实例中,执行“ curl (private ip) 80 ”命令获取 HTML 脚本/转储,但显示错误“ curl”也无法连接到服务器。
When you click a link in a webpage, those two web servers aren't talking to each other, your web browser is talking directly to both servers.当您单击网页中的链接时,这两个 web 服务器不会相互通信,您的 web 浏览器正在直接与两个服务器通信。 In this scenario you cannot have one of the servers in a private subnet.
在这种情况下,您不能在私有子网中拥有其中一台服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.