【发布时间】:2015-04-27 20:35:18
【问题描述】:
在设置运行 CentOS7 的 vagrant 后,我无法连接到 mean.io 服务器。我有端口转发并禁用/打开防火墙,但在 wget 或 curl -v 上仍然没有响应。
我已自动执行以下步骤以达到我现在的位置:
git clone git@github.com:Scrier/Vagrant.git
cd Vagrant/mean
vagrant up
在这里我得到了端口转发设置的输出:
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Couldn't find Cheffile at ./Cheffile.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 3000 => 3000 (adapter 1)
default: 35729 => 35729 (adapter 1)
default: 80 => 8888 (adapter 1)
default: 22 => 2222 (adapter 1)
...
下一步是在 Vagrant 内部:
vagrant ssh
cd /vagrant
sudo ./install.sh
sudo npm install -g gulp
sudo npm install -g bower
sudo npm install -g mean-cli
最后 3 个命令有时不起作用,在后面的步骤中抱怨某些 npm:s 归 root 所有。不知道是什么触发了这个。
接下来我在 /vagrant 中创建一个测试项目
mean init test
然后我尝试作为 gulp (cd test && npm install && gulp) 或服务器 (node server) 运行
默认应用程序启动良好并开始侦听端口 3000。我可以在 vagrant 上 curl 并在服务器应答的情况下在 localhost 上执行 wget。
curl 'http://localhost:3000'
wget 'http://localhost:3000'
从 vagrant 外部执行此操作会锁定,经过 3 天的搜索,我现在无法在网上找到更多帮助。
curl -v 'http://localhost:3000'
wget 'http://localhost:3000'
给出这个输出:
Andreass-MBP:~ andreasjoelsson$ wget 'http://localhost:3000'
--2015-04-21 20:50:30-- http://localhost:3000/
Resolving localhost... 127.0.0.1, ::1, fe80::1
Connecting to localhost|127.0.0.1|:3000... connected.
HTTP request sent, awaiting response... ^C
Andreass-MBP:~ andreasjoelsson$ curl -v 'http://localhost:3000'
* Rebuilt URL to: http://localhost:3000/
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:3000
> Accept: */*
>
^C
都停止响应。
我已经阅读了关于设置 ip 0.0.0.0 而不是 localhost 来解决运行 nodejs 的类似问题,但是我找不到任何有意义的配置。
【问题讨论】: