流浪的端口转发不工作 [英] Vagrant's port forwarding not working

查看:152
本文介绍了流浪的端口转发不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个小问题在年底入门指南流浪汉 。我工作在具有Apache2的运行(通过木偶配置)一个CentOS basebox。我设置了端口转发,使用以下行 Vagrantfile Web请求:

I'm running into a small problem at the end of the Getting Started guide for vagrant. I'm working on a CentOS basebox that has Apache2 running (provisioning via Puppet). I've set up port forwarding for web requests using the following line in Vagrantfile:

 config.vm.forward_port "web", 80, 4567

但是,当我提出请求到该端口,他们失败了。通过Safari浏览器报告的错误是Safari无法打开网页的http://本地主机:4567 /,因为服务器意外下降的连接​​

But when I make requests to that port, they fail. The error reported by Safari is 'Safari can’t open the page "http://localhost:4567/" because the server unexpectedly dropped the connection.'

我做了一个流浪汉重装,看到[默认] - 网页:80 => 4567(适配器1)中的滚动,所以我应该在哪里开始解决此?谢谢你。

I did a vagrant reload and saw "[default] -- web: 80 => 4567 (adapter 1)" in the scroll, so where should I begin to troubleshoot this? Thanks.

推荐答案

我会让这一个实际的答案,而不仅仅是更多的评论。

I'll make this an actual answer instead of just more comments.

第一件事:尽量卷曲的http:80:// localhost'的从虚拟机内。如果还是不行,那么它肯定不是端口转发。

First thing: try curl 'http://localhost:80' from within the VM. If that doesn't work, then it's definitely not the port forwarding.

下一页:尝试卷曲-v的http:4567 /:// localhost'的从你的主机。卷曲可能会给你比Safari浏览器更好的错误消息。

Next: try curl -v 'http://localhost:4567/' from your host machine. Curl might give you a better error message than Safari.

我要检查有没有设置防火墙限制访问端口80的默认流浪VM(Ubuntu的)不来设置防火墙,但你说你用别的东西,所以它可能是值得的检查。

I'd check that there are no firewalls set up restricting access to port 80. The default Vagrant VM (Ubuntu) doesn't come with a firewall set up, but you said you're using something else, so it might be worth it to check.

如果这不是它,尝试使比Apache等你可以使用一个简单的HTTP服务器的端口80上的Python船舶上市的东西 - 转到文件夹 index.html的并运行 sudo的蟒蛇-m SimpleHTTPServer 80 ,然后尝试命中与从两个箱子卷曲。如果这样的作品,那么它可能是一个Apache的配置问题。我没有与Apache足够的经验来帮助,如果是这样的话(我使用nginx的)。

If that's not it, try making something other than Apache listed on port 80. Python ships with a simple HTTP server you can use -- go to the folder with index.html and run sudo python -m SimpleHTTPServer 80, then try hitting that with curl from both boxes. If that works, then it's probably an Apache configuration issue. I don't have enough experience with Apache to help if that's the case (I use nginx).

这篇关于流浪的端口转发不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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