簡體   English   中英

無法連接到Fedora 21上的Rails服務器

[英]Cannot connect to rails server on Fedora 21

我啟動了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)

我應該檢查並修復什么?

解決! 我必須使用-b使Rails服務器不僅可以在本地主機上工作。

$ rails s -b 0.0.0.0

它已更改: https : //github.com/rack/rack/commit/28b014484a8ac0bbb388e7eaeeef159598ec64fc

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM