无法连接到Centos 6.3上的Ruby on Rails开发服务器

我无法连接到我的 Ruby on Rails开发服务器:

当我在不同的连接上输入192.168.0.10:3000进入Web浏览器时,只需要超时.

我怀疑问题出在我的防火墙配置上,但我试图打开所有内容,但这似乎不起作用.

服务器在我的本地网络上,具有静态IP并且配置正确 – 我可以通过SSH连接到盒子,它可以连接到互联网进行更新.它正在运行CentOS 6.3,我按照这些说明安装了rails:http://itekblog.com/ruby-on-rails-on-centos-6-3-is-easy/

服务器正在运行:我可以使用wget localhost:3000下载“Welcome Aboard”页面

我认为应该监听所有接口:

[sandy@pops testproject4]$rails server
=> Booting WEBrick
=> Rails 3.2.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-08-18 18:29:04] INFO  WEBrick 1.3.1
[2012-08-18 18:29:04] INFO  ruby 1.8.7 (2011-06-30) [i386-linux]
[2012-08-18 18:29:04] INFO  WEBrick::HTTPServer#start: pid=9881 port=3000

我想我已经打开了所有端口

[sandy@pops testproject4]$sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 
ACCEPT     all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

任何帮助解决这个问题将非常感激

看起来问题是由于当你添加了你打开的所有行时你使用iptables -A INPUT …它在REJECT all规则之后尽职尽责地将它添加到INPUT链的末尾.

由于iptables在第一场比赛中胜出,因此您接受所有规则永远不会匹配,因此端口3000被阻止.

您应该使用iptables -I …将规则插入到链中或特定位置的特定位置

iptables -I INPUT -p tcp --dport 3000 -j ACCEPT

应该做你想做的事.

如果你想保存规则,那么重启后一切都会好的,做:

service iptables save

相关文章

linux下开机自启: 在/etc/init.d目录下新建文件elasticsear...
1、因为在centos7中/etc/rc.d/rc.local的权限被降低了,所以...
最简单的查看方法可以使用ls -ll、ls-lh命令进行查看,当使用...
ASP.NET Core应用程序发布linux在shell中运行是正常的。可一...
设置时区(CentOS 7) 先执行命令timedatectl status|grep &...
vim /etc/sysconfig/network-scripts/ifcfg-eth0 B...