我开始rails server
,但http://192.168.56.104:3000
无效。它的地址是正确的,因为我可以在http://192.168.56.104:80
看到Apache的测试页面。
我启动了服务器:
$ rails s
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-03-10 09:45:49] INFO WEBrick 1.3.1
[2015-03-10 09:45:49] INFO ruby 2.1.5 (2014-11-13) [x86_64-linux]
[2015-03-10 09:45:49] INFO WEBrick::HTTPServer#start: pid=5512 port=3000
然后它正在运作:
# wget http://localhost:3000; head index.html
--2015-03-10 09:53:39-- http://localhost:3000/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:3000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14935 (15K) [text/html]
Saving to: ‘index.html’
index.html 100%[=================>] 14.58K --.-KB/s in 0.001s
2015-03-10 09:53:39 (18.1 MB/s) - ‘index.html’ saved [14935/14935]
<!DOCTYPE html>
<html>
<head>
<title>Ruby on Rails: Welcome aboard</title>
<style media="screen">
body {
margin: 0;
margin-bottom: 25px;
padding: 0;
background-color: #f0f0f0;
IP:
# ip r
default via 10.0.2.2 dev enp0s3 proto static metric 1024
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15
192.168.56.0/24 dev enp0s8 proto kernel scope link src 192.168.56.104
防火墙设置为:
# firewall-cmd --list-all
FedoraServer (default, active)
interfaces: enp0s3 enp0s8
sources:
services: cockpit dhcpv6-client http ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
和
# firewall-cmd --permanent --zone=FedoraServer --list-all
FedoraServer (default)
interfaces:
sources:
services: cockpit dhcpv6-client http ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
和
# cat /etc/firewalld/services/http.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>WWW (HTTP)</short>
<description>HTTP is the protocol used to serve Web pages. If you plan to make your Web server publicly available, enable this option. This option is not required for viewing pages locally or developing Web pages.</description>
<port protocol="tcp" port="3000"/>
<port protocol="tcp" port="80"/>
</service>
我正在使用Fedora 21。
# cat /etc/fedora-release
Fedora release 21 (Twenty One)
我应该检查和修复什么?
答案 0 :(得分:0)
解决!我必须使用-b
来使用rails服务器,而不仅仅是localhost。
$ rails s -b 0.0.0.0
更改了:https://github.com/rack/rack/commit/28b014484a8ac0bbb388e7eaeeef159598ec64fc