通过 rails s 启动 WEBrick ,出现以下问题:3000端口除了本机,其他机器无法访问(防火墙已经关闭)
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-01-20 01:14:37] INFO WEBrick 1.3.1
[2016-01-20 01:14:37] INFO ruby 2.2.1 (2015-02-26) [x86_64-linux]
[2016-01-20 01:14:37] INFO WEBrick::HTTPServer#start: pid=2482 port=3000
with rails 4.2.0, the server binds to localhost by default, instead of 0.0.0.0. When working with a rails in a virtual box, accessing the server from the host computer, the binding address needs to be 0.0.0.0
Start rails server with -b0.0.0.0 to make the rails server accessible from the host computer/browser.
[roamer@ror_server demo]$ rails s -b0.0.0.0
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-01-20 01:21:05] INFO WEBrick 1.3.1
[2016-01-20 01:21:05] INFO ruby 2.2.1 (2015-02-26) [x86_64-linux]
[2016-01-20 01:21:05] INFO WEBrick::HTTPServer#start: pid=2580 port=3000