如何在不是“localhost”的域上运行本地Rails实例?

时间:2016-03-05 18:58:54

标签: ruby-on-rails localhost alias hosts

我在Mac Yosemite上使用Rails 4.2.3。我正在尝试为我的本地计算机设置别名,以便我可以在浏览器中输入“http://devbox.example.com:3000/”并让我的本地Rails实例为这些页面提供服务。但我似乎无法做到这一点。我在/ etc / hosts文件中设置了它

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1       devbox.example.com

但是当我启动我的Rails服务器(“rails s”)时,我可以访问“http:///localhost:3000/”就好了,但当我尝试访问“http://devbox.example.com:3000/”时,我得到一个“无法访问”连接“错误。什么是陌生人,当服务器运行时,ping我设置的别名解析为127.0.0.1 ......

localhost:myapp davea$ ping devbox.example.com
PING devbox.example.com (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.056 ms

我需要在Rails中做些什么来让我的服务器在我设置的别名上运行?

1 个答案:

答案 0 :(得分:3)

"PrerenderIO": { "token": "mytoken", "host": "yourwebsite.com", "protocol": "https" } rails s -b 0.0.0.0或bind选项将允许您设置rails服务器绑定的IP地址。如果您有多个连接器,则可以设置一个特定的连接器。

相关问题