问题原文
原帖链接 · neustart47 · CC BY-SA 3.0
I have an API which I successfully hosted on Amazon AMI instance. I know that's for sure because I can use it locally using curl. Api hosted on port 8080.
That's what I putted into cmd for open port:
su
iptables -I INPUT -p tcp --dport 8080 -m state --state NEW -j ACCEPT
service iptables save
/etc/init.d/iptables restart
I turned the firewall off as well:
service iptables save
service iptables stop
chkconfig iptables off
That's how my out/in rules looks in AWS console:
And I still can't reach my app via server public IP from outside. Why that's happening?
UPDATE
Result for /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
UPDATE 2
netstat -ltpn result:
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 -
已采纳解答
原帖链接 · dsmsk80 · CC BY-SA 3.0
From the netstat output, it seems that your app is listening on loop-back interface only - 127.0.0.1:8080 and so you are not able to connect to it outside of the instance.
See e.g. ssh service - 0.0.0.0:22. This means the service is listening on "all network interfaces".
You need to reconfigure your application to make it listening not only on loop-back.
Another solution could be to add iptables DNAT rule so incoming requests are forwarded to the loop-back interface.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
