为什么Ruby on Rails为什么使用http://0.0.0.0:3000而不是http://localhost:3000? [英] Why does Ruby on Rails use http://0.0.0.0:3000 instead of http://localhost:3000?

查看:117
本文介绍了为什么Ruby on Rails为什么使用http://0.0.0.0:3000而不是http://localhost:3000?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Ruby on Rails 来说还很陌生,因此当我尝试遵循官方的"入门" Ruby on Rails教程时,我有点失望,因为它去了很快就错了.基本上说:

I am very new to Ruby on Rails so when I tried to follow the official "Getting Started" ruby on rails tutorial, I was a bit disappointed because it went wrong very quickly. Basically it said :

…导航到 http://localhost:3000 .您应该看到Rails的默认信息页面.

…navigate to http://localhost:3000. You should see Rails’ default information page.

但是当我按照说明进行操作时,我会得到

But when I follow the instructions, I get


=> Rails 2.3.4 application starting on http://0.0.0.0:3000

尝试两个地址后,我知道它们指向同一件事,但是有人可以向我解释为什么Ruby on Rails使用http://0.0.0.0:3000而不是http://localhost:3000吗?

After trying both addresses, I know that they point to the same thing, but can someone explain to me why Ruby on Rails uses http://0.0.0.0:3000 instead of http://localhost:3000 ?

有没有办法让WEBbrick服务器始终使用localhost?

Is there a way to always have the WEBbrick server use localhost ?

推荐答案

Localhost的字面意思是您的本地主机",通常由127.0.0.1标识,并且到该地址的所有流量都通过回送接口路由.如果您的Web服务器正在侦听127.0.0.1上的连接,则意味着它仅接受来自同一主机的请求.

Localhost means quite literally "your local host", usually identified by 127.0.0.1 and all traffic to that address is routed via a loopback interface. If your Web server is listening for connections on 127.0.0.1, this means that it only accepts requests coming from the same host.

0.0.0.0意味着Rails正在监听所有接口,而不仅仅是回送接口.

0.0.0.0 means that Rails is listening on all interfaces, not just the loopback interface.

这篇关于为什么Ruby on Rails为什么使用http://0.0.0.0:3000而不是http://localhost:3000?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆