[英]Connecting rails server from local machine to network
I have made a rails application using 4.2.0 in my local Ubuntu machine. 我已经在本地Ubuntu计算机上使用4.2.0制作了Rails应用程序。 I want to deploy that application to local network of my campus.
我想将该应用程序部署到我的校园的本地网络。 How can I do that?
我怎样才能做到这一点?
I checked my ip from ifconfig, and deployed the webrick server via binding that ip and different ports too, 我从ifconfig中检查了我的IP,并通过绑定该IP和其他端口来部署了Webrick服务器,
rails server -b my_ip -p port
the console says that the application is running in that ip and port but when I am trying to connect it via my browser, I get service timout error. 控制台说该应用程序正在该ip和端口中运行,但是当我尝试通过浏览器连接该应用程序时,出现服务timout错误。 Can anybody suggest me a method to do that?
有人可以建议我这样做吗?
Binding to 0.0.0.0 tells the service to bind to all IP addresses on your machine. 绑定到0.0.0.0告诉服务绑定到计算机上的所有IP地址。 Rails server used to do this by default, but with 4.2 changed to binding only to localhost.
Rails服务器默认情况下会执行此操作,但是4.2更改为仅绑定到localhost。
Basically if it's only bound to localhost then it will only respond locally to either localhost or 127.0.0.1 which can't work through a DNS service because it's not a public IP address. 基本上,如果仅绑定到本地主机,则它将仅本地响应本地主机或127.0.0.1,而本地主机或127.0.0.1无法通过DNS服务工作,因为它不是公共IP地址。
When you use 0.0.0.0 it will bind to localhost and to your routable IP address. 当您使用0.0.0.0时,它将绑定到localhost和您的可路由IP地址。 Use rails s -b 0.0.0.0
使用rails s -b 0.0.0.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.