我有一个成功托pipe在Amazon AMI实例上的API。 我知道这是肯定的,因为我可以在本地使用curl来使用它。 API托pipe在端口8080上。
这就是我打开的端口cmd的内容:
su iptables -I INPUT -p tcp --dport 8080 -m state --state NEW -j ACCEPT service iptables save /etc/init.d/iptables restart
我也closures了防火墙:
service iptables save service iptables stop chkconfig iptables off
这就是我的出/入规则在AWS控制台中的外观:
而我仍然无法通过服务器公共IP从外部访问我的应用程序。 为什么会这样?
UPDATE
/sbin/iptables -L :
Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
更新2
netstat -ltpn结果:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 3941/uwsgi tcp 0 0 0.0.0.0:58704 0.0.0.0:* LISTEN - tcp 0 0 :::45589 :::* LISTEN - tcp 0 0 :::22 :::* LISTEN - tcp 0 0 :::111 :::* LISTEN -
从netstat输出看来,您的应用程序似乎只在回送接口上进行侦听 – 127.0.0.1:8080 ,因此您无法在实例外连接到该接口。
参见例如ssh服务 – 0.0.0.0:22 。 这意味着服务正在监听“所有networking接口”。
您需要重新configuration您的应用程序,使其不仅能够在回送环境中进行监听。
另一个解决scheme可以是添加iptables DNAT规则,以便传入的请求被转发到环回接口。
我将查看与已部署的实例关联的安全组,并确保它允许端口8080上的入站通信。networkingACL和安全组都需要允许通信。
你可以在这里find关于安全组的更多信息: http : //docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html