无法通过托pipe在公有子网中的NAT连接到托pipe在VPC私有子网中的Web服务器

我已将我的android / web应用程序托pipe在VPC的专用子网(10.0.1.0)中的EC2实例上。 这个实例上安装了apache-tomcat,但是没有公有IP。

我的VPC的公有子网(10.0.0.0)中也有一个NAT实例,公有IP分配给服务器。

iptablesconfiguration看起来像这样:

[ec2-user@ip-10-0-0-21 ~]$ sudo iptables -t nat -L --line-numbers Chain PREROUTING (policy ACCEPT) num target prot opt source destination 1 DNAT tcp -- anywhere anywhere tcp dpt:webcache to:10.0.1.11:8080 2 DNAT tcp -- anywhere anywhere tcp dpt:http to:10.0.1.11:8080 3 DNAT tcp -- anywhere anywhere tcp dpt:http to:10.0.1.11:8080 4 DNAT tcp -- anywhere anywhere tcp dpt:https to:10.0.1.11:8080 Chain INPUT (policy ACCEPT) num target prot opt source destination Chain OUTPUT (policy ACCEPT) num target prot opt source destination Chain POSTROUTING (policy ACCEPT) num target prot opt source destination 1 MASQUERADE all -- ip-10-0-0-0.ap-southeast-1.compute.internal/16 anywhere 2 MASQUERADE all -- ip-10-0-1-0.ap-southeast-1.compute.internal/24 anywhere [ec2-user@ip-10-0-0-21 ~]$ sudo iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to XX.XX.XX.XX 

尽pipe这些设置,当我尝试连接到我的NAT服务器的公共DNS时,我得到一个ERR_CONNECTION_TIMED_OUT错误。 如果我的连接请求打到apache服务器,我应该至less得到一个404。

我已通过NAT服务器检查了我的Web服务器(在私有子网中)与Internet的连接。 pingwget google.com时,我会得到有效的回复。

 [ec2-user@ip-10-0-1-11 ~]$ ping google.com PING google.com (173.194.117.97) 56(84) bytes of data. 64 bytes from sin01s17-in-f1.1e100.net (173.194.117.97): icmp_seq=1 ttl=56 time=3.54 ms 64 bytes from sin01s17-in-f1.1e100.net (173.194.117.97): icmp_seq=2 ttl=56 time=3.57 ms 64 bytes from sin01s17-in-f1.1e100.net (173.194.117.97): icmp_seq=3 ttl=56 time=3.65 ms 64 bytes from sin01s17-in-f1.1e100.net (173.194.117.97): icmp_seq=4 ttl=56 time=3.79 ms 64 bytes from sin01s17-in-f1.1e100.net (173.194.117.97): icmp_seq=5 ttl=56 time=3.61 ms ^C --- google.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4990ms rtt min/avg/max/mdev = 3.546/3.637/3.799/0.116 ms [ec2-user@ip-10-0-1-11 ~]$ wget google.com --2015-09-02 05:22:01-- http://google.com/ Resolving google.com (google.com)... 173.194.117.96, 173.194.117.97, 173.194.117.98, ... Connecting to google.com (google.com)|173.194.117.96|:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/html] Saving to: 'index.html.1' index.html.1 [ <=> ] 10.97K --.-KB/s in 0.001s 2015-09-02 05:22:02 (12.7 MB/s) - 'index.html.1' saved [11230] 

有人可以指出这个设置有什么问题吗?

其他信息:每当我ping我的NAT服务器的公共IP时,日志显示一些垃圾请求击中我的Web服务器。 我完全无能为力

 10.0.0.21 - - [02/Sep/2015:06:12:41 +0000] "??]7{]?zɳM?˗?9?G?68???l?xW???D?+?/?,?0?????#?'? ??$?(? " 400 - 10.0.0.21 - - [02/Sep/2015:06:12:41 +0000] "????]f???}???Q?ݹ?U}??????A?#?0D?+?/?,?0?????#?'? ??$?(? " 400 - 10.0.0.21 - - [02/Sep/2015:06:12:42 +0000] "???????{}?hA??????? j?W??P?ߠD?+?/?,?0?????#?'? ??$?(? " 400 -