无法从外面到达Vagrant上的Jekyll服务器

时间:2014-12-23 09:10:15

标签: vagrant jekyll

我已经使用hashicorp / precise32框构建了一个Vagrant虚拟机,并在其上安装了Jekyll。我在Vagrantfile上设置了端口4000转发:

config.vm.network :forwarded_port, host: 4000, guest: 4000

当我尝试jekyll server时,似乎一切正常,但我无法从外部到达服务器。

Configuration file: /vagrant/test-site/_config.yml
Source: /vagrant/test-site
Destination: /vagrant/test-site/_site
Generating...
                done.
Auto-regeneration: enabled for '/vagrant/test-site'
Configuration file: /vagrant/test-site/_config.yml
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.

当我尝试通过curl到达服务器时,输出为:

curl: (56) Recv failure: Connection was aborted

我已尝试使用同一端口上的其他服务器,我可以联系到它们,因此这似乎不是转发问题。

有什么想法吗?

编辑:

curl localhost:4000在VM内正常运行。出于某种原因,Jekyll的端口转发工作不正常。

1 个答案:

答案 0 :(得分:44)

错误发生在Server address: http://127.0.0.1:4000/。似乎localhost是Jekyll的默认主机,所以我需要运行jekyll serve --host 0.0.0.0以便服务器可以从外面使用。

我在这里找到答案:Vagrant port forwarding not working. Cups not accesible from host