简体   繁体   English

如何在 AWS VPC 的私有子网中连接 AWS EC2 实例后面的网页

[英]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.

相关问题 SSH 连接到位于 VPC 私有子网中的 AWS EC2 实例 - SSH'ing into AWS EC2 Instance located in Private Subnet in a VPC AWS - 无法 ping VPC 中私有子网上的 EC2 实例 - AWS - Cannot ping EC2 instance on private subnet in VPC AWS VPC - 无法从私有子网中的堡垒主机通过 SSH 连接到不同子网中同一 VPC 中的 EC2 实例 - AWS VPC - Cannot SSH from Bastion Host in private subnet to EC2 instance in the same VPC in a different subnet 从NAT实例后面的AWS VPC私有子网访问ftp - ftp access from AWS VPC private subnet behind a NAT instance 如何使用 aws-sdk 在 vpc 和子网上创建 ec2 实例? - How to use aws-sdk for creating ec2 instance on a vpc and subnet? 如何在 AWS 中 ping 在同一 vpc 同一子网但不同安全组中运行的 EC2 实例 - How to ping an EC2 instance running in the same vpc same subnet but different security group in AWS 私有子网中的 AWS EC2 实例无法通过 NAT 网关连接到互联网 - AWS EC2 instance in private subnet unable to connect to internet via NAT gateway 如何使用mySQLworkbench连接到AWS私有子网VPC中的RDS - How to use mySQLworkbench to connect to RDS in AWS private subnet VPC AWS - 在同一个公共子网中连接一个带有私有 ip 的 ec2 实例和一个带有公共 ip 的 ec2 实例? - AWS - Connecting an ec2 instance with a private ip and an ec2 instance with a public ip in the same public subnet? 在AWS私有子网EC2中使用yum - use yum in AWS private subnet EC2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM