无法从同一网络上的另一台计算机访问本地 Sinatra 服务器 [英] Cannot access local Sinatra server from another computer on same network
问题描述
我有一个通过 textmate 运行的简单 Sinatra 服务器,但我无法从同一网络上的另一台计算机访问.
I have a simple Sinatra server that I run through textmate but I can't access from another computer on the same network.
我在 Mac OS 10.8.3 上运行 Ruby 1.9.3p327 和 Sinatra 1.4.1.防火墙已禁用.
I'm running Ruby 1.9.3p327 and Sinatra 1.4.1 on a Mac OS 10.8.3. Firewall is disabled.
我在不同的网络和计算机上测试了相同的场景.
I tested the same scenario on different networks and computers.
计算机响应简单的 ping,但是当我尝试 telnet 端口 4567 时,我无法建立连接.
The computer responds to simple pings but when I try to telnet port 4567 I can't establish a connection.
推荐答案
最近提交了 Sinatra出于安全考虑,在开发模式下将默认侦听地址从 0.0.0.0
更改为 localhost
.
There was a recent commit to Sinatra that changed the default listen address to localhost
from 0.0.0.0
in development mode due to security concerns.
为了明确允许从网络访问,您需要以另一种模式(例如生产)运行您的应用程序,或者设置 bind
选项 到 0.0.0.0
.
In order to explicitly allow access from the network, you need to either run your app in another mode (e.g. production), or set the bind
option to 0.0.0.0
.
您可以使用内置服务器使用 -o
选项从命令行执行此操作:
You can do this from the command line using the built in server using the -o
option:
$ ./my_sinatra_file.rb -o 0.0.0.0
这篇关于无法从同一网络上的另一台计算机访问本地 Sinatra 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!