使用局域网中的移动设备连接到本地构建的Jekyll服务器 [英] Connect to a locally built Jekyll Server using mobile devices in the LAN

查看:292
本文介绍了使用局域网中的移动设备连接到本地构建的Jekyll服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一台机器上使用 jekyll serve 后,会建立一个WEBrick服务器,并且可以从 localhost:4000

但是,我想知道如何从局域网中的其他机器访问此Web服务器,尤其是移动设备?我试图在将代码推送到Github之前在移动设备上测试jekyll站点。 试试 jekyll serve --host = 0.0.0.0 当你在命令行调用Jekyll时。



这将使Jekyll的HTTP服务器绑定到所有可用的IP地址,而不仅仅是 localhost



您也可以将它添加到 _config.yml 主机:0.0.0.0 。 GitHub会在推送时忽略这一点,所以如果您不介意在网络上公开访问您的工作,则可以安全使用。






没有 - host = 0.0.0.0 当你启动时,Jekyll会输出这样的内容:

  $ jekyll服务
[...]
服务器地址:http://127.0.0.1:4000/
服务器正在运行...新闻ctrl-c停止。

但是 - host = 0.0.0.0 (或 host:0.0.0.0 in _config.yml ),您会注意到它正在监听所有接口由 0.0.0.0 )表示,而不仅仅是监听环回接口(由 127.0.0.1 表示)

  $ jekyll serve --host = 0.0.0.0 
[...]
服务器地址:http:/ /0.0.0.0:4000/
服务器正在运行...按下ctrl-c停止。


After using jekyll serve on one machine, a WEBrick server is set up and the site can be accessed from localhost:4000 on this particular PC.

However, I'm wondering how to access this web server from other machines in the LAN, especially for mobile devices? I'm trying to test the jekyll site on mobile devices before pushing the code to Github.

解决方案

Try jekyll serve --host=0.0.0.0 when you invoke Jekyll on the command line.

That will make Jekyll's HTTP server bind to all available IPs, rather than just to localhost.

You can also add this to your _config.yml with host: 0.0.0.0. GitHub will simply ignore this when you push, so it's safe to use if you don't mind having your work openly accessible on your network.


Without --host=0.0.0.0 Jekyll will output something like this when you start up:

$ jekyll serve
[...]
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.

But with --host=0.0.0.0 (or host: 0.0.0.0 in _config.yml) you'll notice that it's listening on all interfaces (represented by 0.0.0.0) rather than just listening on the loopback interface (represented by 127.0.0.1)

$ jekyll serve --host=0.0.0.0
[...]
Server address: http://0.0.0.0:4000/
Server running... press ctrl-c to stop. 

这篇关于使用局域网中的移动设备连接到本地构建的Jekyll服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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