无法从外部访问Vagrant上的Jekyll服务器 [英] Cannot reach Jekyll server on Vagrant from outside

查看:37
本文介绍了无法从外部访问Vagrant上的Jekyll服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用hashicorp/precise32盒构建了一个Vagrant VM,并在其上安装了Jekyll.我在Vagrantfile上设置了端口4000转发:

I've built a Vagrant VM with hashicorp/precise32 box and installed Jekyll on it. I've set port 4000 forwarding on Vagrantfile:

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

当我尝试jekyll server时,似乎一切正常,但是我无法从外部访问服务器.

When I try jekyll server it seems everything works fine, but I cannot reach the server from outside.

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到达服务器时,输出为:

When I try to reach the server via curl, the output is:

curl: (56) Recv failure: Connection was aborted

我已经尝试过使用同一端口上的其他服务器,并且可以访问它们,所以这似乎不是转发问题.

I've tried with other servers on same port and I can reach them, so it not seems a forwarding problem.

有什么主意吗?

curl localhost:4000在VM中可以正常工作.由于某些原因,端口转发对于Jekyll无法正常工作.

curl localhost:4000 works correctly inside VM. For some reason, the port forwarding is not working properly for Jekyll.

推荐答案

错误出现在Server address: http://127.0.0.1:4000/上.似乎localhost是Jekyll的默认主机,因此我需要运行jekyll serve --host 0.0.0.0以便从外部访问该服务器.

The error was on Server address: http://127.0.0.1:4000/. It seems that localhost is the default host for Jekyll, so I need to run jekyll serve --host 0.0.0.0 for the server to be available from outside.

我在这里找到答案:无用的端口转发不起作用.主办方无法进入杯赛

这篇关于无法从外部访问Vagrant上的Jekyll服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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