首页 文章

Yosemite在WiFi上升级到10.10.3后,Rails服务器在网络上不可见

提问于
浏览
0

我在我的机器上运行了一个可用于本地网络的rails服务器,一切正常,我可以使用本地服装192.168.xx:3000从其他设备访问我的服务器,在更新操作系统到10.10.3之后(我以前有优胜美地,但我不记得版本)这不再有效,我的防火墙被禁用,我试图使用“rails server --binding = 0.0.0.0”启动服务器,但它仍然不可见其他网络上的设备 .

编辑:我现在看到问题是只有当我使用WIFI如果我通过霹雳和以太网连接一切正常

有谁知道如何解决这个问题?

谢谢!

2 回答

  • 0

    问题似乎是无线路由器需要重新启动,在我尝试了一切,重新启动mac(服务器运行的那个)和我尝试连接的设备之后,我重新启动了路由器,如果出于某些奇怪的原因它开始起作用了 .

    也许这个信息会帮助别人

  • 0

    再次工作!

    MacOS Yosemite完全删除了ipfw(IP-Firewall),现在只使用pf(数据包过滤器) . 所以所有的默认转发,我们已经习惯了!

    为了让它再次运行,我使用了这个很棒的教程:来自Sal Ferrarello的Mac pfctl Port Forwarding并将其更改为支持常用的rails服务器 . 把它放在终端,然后再次运行!

    处理成功(终端命令)

    activate rails port forwarding (如果需要,可添加更多)

    echo "
    rdr pass inet proto tcp from any to any port 3000 -> 127.0.0.1 port 3000
    rdr pass inet proto tcp from any to any port 3001 -> 127.0.0.1 port 3001
    rdr pass inet proto tcp from any to any port 3002 -> 127.0.0.1 port 3002
    rdr pass inet proto tcp from any to any port 3003 -> 127.0.0.1 port 3003
    rdr pass inet proto tcp from any to any port 3004 -> 127.0.0.1 port 3004
    rdr pass inet proto tcp from any to any port 3005 -> 127.0.0.1 port 3005
    rdr pass inet proto tcp from any to any port 3006 -> 127.0.0.1 port 3006
    rdr pass inet proto tcp from any to any port 3007 -> 127.0.0.1 port 3007
    rdr pass inet proto tcp from any to any port 3008 -> 127.0.0.1 port 3008
    rdr pass inet proto tcp from any to any port 3009 -> 127.0.0.1 port 3009
    rdr pass inet proto tcp from any to any port 3010 -> 127.0.0.1 port 3010
    rdr pass inet proto tcp from any to any port 4242 -> 127.0.0.1 port 4242
    rdr pass inet proto tcp from any to any port 9292 -> 127.0.0.1 port 9292
    " | sudo pfctl -ef -
    

    show current forwarding rules (检查哪些规则有效)

    sudo pfctl -s nat
    

    stop port forwarding (小心!再次停止!)

    sudo pfctl -F all -f /etc/pf.conf
    

    ..我仍然想念SnowLeopard,这个天,一个开发人员的生活如此轻松..


    更新:

    这只适用于下次重启 . 我尝试了很多让它自动运行,我改变了/etc/pf.conf,我改变了pf守护进程..但没有任何作用!

    所以我制作了自己的守护进程,它只是在启动时加载我的开发端口,效果很好!

    /Library/LaunchDaemons/dev.development.servers.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
            <key>Label</key>
            <string>dev.development.servers</string>
            <key>ProgramArguments</key>
            <array>
                    <string>/bin/sh</string>
                    <string>-c</string>
                    <string>
                      echo "
                      rdr pass inet proto tcp from any to any port 3000 -> 127.0.0.1 port 3000
                      rdr pass inet proto tcp from any to any port 3001 -> 127.0.0.1 port 3001
                      rdr pass inet proto tcp from any to any port 3002 -> 127.0.0.1 port 3002
                      rdr pass inet proto tcp from any to any port 3003 -> 127.0.0.1 port 3003
                      rdr pass inet proto tcp from any to any port 3004 -> 127.0.0.1 port 3004
                      rdr pass inet proto tcp from any to any port 3005 -> 127.0.0.1 port 3005
                      rdr pass inet proto tcp from any to any port 3006 -> 127.0.0.1 port 3006
                      rdr pass inet proto tcp from any to any port 3007 -> 127.0.0.1 port 3007
                      rdr pass inet proto tcp from any to any port 3008 -> 127.0.0.1 port 3008
                      rdr pass inet proto tcp from any to any port 3009 -> 127.0.0.1 port 3009
                      rdr pass inet proto tcp from any to any port 3010 -> 127.0.0.1 port 3010
                      rdr pass inet proto tcp from any to any port 4242 -> 127.0.0.1 port 4242
                      rdr pass inet proto tcp from any to any port 9292 -> 127.0.0.1 port 9292
                      " | sudo pfctl -ef -
                    </string>
            </array>
            <key>RunAtLoad</key>
            <true/>
            <key>UserName</key>
            <string>root</string>
    </dict>
    </plist>
    

相关问题