流浪汉,nodejs和iptable端口转发 [英] Vagrant, nodejs and iptable port forwarding
问题描述
当我尝试在流浪者(在OS X上)上将nodejs用作Web服务器时,我遇到了一个小问题.
我的配置文件在下面链接,我只安装了nodejs和mongodb.
IP框为10.10.56.101
(在学校里我需要一个192.168.56.101
以外的IP地址).
我尝试使用下面链接的小脚本访问nodejs服务器.该脚本仅侦听端口51160
并回答确定".
首先我没有得到任何答案,经过搜索后,我发现我需要进行端口转发并使用iptable起作用(下面链接的命令在端口51160
而不是8000
上).>
我以相同的配置重新安装了无业游民的机器,但我无法使机器正常工作.
我可以从无业游民的计算机中curl localhost:51160
,但是从虚拟机外部什么也收不到.
文件:
- config.yaml: https://gist.github.com/nobe4/0bb16fdb23279d416656
- server.js: https://gist.github.com/nobe4/639d63ef612f247d9309
- iptable命令: https://gist.github.com/kentbrew/776580#file-node-on-ec2-port-80-txt-L39
如果您可以从无业游民的计算机内部curl localhost:51160
,则表明node.js服务是文件.
我没有看到Vagrantfile
,请检查您是否在Vagrantfile
中有以下几行
config.vm.network "forwarded_port", guest: 51160, host: 51160
config.vm.network :private_network, ip: "192.168.56.123" # or other unused IP.
更新后,运行vagrant provision
,然后重试以访问
curl http://192.168.56.123:51160
在您自己的计算机上.
I have a little issue when I try to use nodejs as a web server on vagrant (on OS X).
My config file is linked below, I have only nodejs and mongodb installed.
The box IP is 10.10.56.101
(I needed another ip than 192.168.56.101
to work at my school).
I try to reach the nodejs server with the little script linked below. The script only listen on port 51160
and answer OK.
First I didn't get any answers and after searching I found that I needed to do a port forwarding and with a iptable it worked (the command linked below, on port 51160
instead of 8000
).
I reinstalled the vagrant machine with the same configuration and I wasn't able to get the machine to work anymore.
I can curl localhost:51160
from inside the vagrant machine but I can't get anything from outside the VM.
Files :
- config.yaml : https://gist.github.com/nobe4/0bb16fdb23279d416656
- server.js : https://gist.github.com/nobe4/639d63ef612f247d9309
- iptable command : https://gist.github.com/kentbrew/776580#file-node-on-ec2-port-80-txt-L39
if you can curl localhost:51160
from inside the vagrant machine, that means node.js service is file.
I didn't see the Vagrantfile
, please check you have below lines in Vagrantfile
config.vm.network "forwarded_port", guest: 51160, host: 51160
config.vm.network :private_network, ip: "192.168.56.123" # or other unused IP.
After updated, run vagrant provision
, and try again to access by
curl http://192.168.56.123:51160
from your own computer.
这篇关于流浪汉,nodejs和iptable端口转发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!