Satrajit
Satrajit

Reputation: 1

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. I have put 1 EC2 instances in each of the subnets. Both the EC2 instances have Apache http server running in port 80 and have a HTML page. Say, there in Page1.html in the Public EC2 instance and Page2.html in the Private EC2 instance. Page1.html in Public EC2 instance has a URL that points to Page2.html in Private EC2 instance.
All the Security Groups are open to all traffic and the NAT Gateway is allocated with a Elastic IP.

When I put (http:// public IP address:80/Page1.html) in browser I get the Page1.html displayed. But when I click the link on Page1.html which points to Page2.html in Private EC2 instance, the Page2.html is not displayed. The request eventually times out.

Is there a way I can make these 2 Apache servers talking to each other?

It may worth noting that:

i) I can ping the (private ip) from the public instance.

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!"

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.

Upvotes: 0

Views: 1029

Answers (1)

Mark B
Mark B

Reputation: 200446

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. In this scenario you cannot have one of the servers in a private subnet.

Upvotes: 1

Related Questions