我在端口80上运行Apache,在端口3000上运行Rails(Webrick)。
使用http://localhost
和http://localhost:3000
,我可以看到两个服务器。 但是,使用本地IP,我仍然可以看到Apache serv,但是看不到Rails serv。
再次运行cURL,Apache返回200,但是Rails返回curl: (7) Failed to connect to <ip> port 3000: Connection refused
更新资料
我使用-b
IP绑定选项和IP重新启动了服务器,但无法再从localhost:3000命中它。 有没有办法绑定到两者?
传递0.0.0.0
作为参数。 那将绑定到所有接口。
如果要永久config/boot.rb
可以通过在config/boot.rb
添加以下内容来修补一些Rails:
require 'rails/commands/server'
module Rails
class Server
def default_options
super.merge(Host: '0.0.0.0', Port: 3000)
end
end
end
请记住,如果您在共享网络上,这将使其公开可用。