简体   繁体   English

将Rails服务器从本地计算机连接到网络

[英]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.

相关问题 从本地网络访问Webrick Rails Server - Access Webrick Rails Server from local network 从Rails 4.2中的网络上的另一台计算机访问本地主机 - Access local host from another machine on network in rails 4.2 将Rails应用程序从本地计算机部署到cPanel VPS服务器 - Deploy Rails application from local machine to cPanel VPS server 通过本地网络连接到 WSL2 服务器 - Connecting to WSL2 server via local network 从我的WebApp连接到用户本地计算机 - Connecting to users local machine from my WebApp 无法连接到本地计算机上的Rails服务器 - Can't connect to rails server on local machine 从Rails在本地计算机上执行命令 - Execute a command on the local machine from Rails 我如何从本地网络上的其他计算机上查看我的Apache Rails服务器? - How can i see my apache rails server from other computers on my local network? 从Rails控制台连接到另一台服务器上的mongodb - Connecting to mongodb on different server from rails console Rails应用程序(在本地计算机上)可以在没有在本地计算机上设置mysql的情况下连接到远程数据库(在登台服务器上)吗? - Can a rails app (on local machine) connect to a remote database (on staging server) without having mysql setup on the local machine?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM