流浪汉,nodejs和iptable端口转发 [英] Vagrant, nodejs and iptable port forwarding

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

问题描述

当我尝试在流浪者(在OS X上)上将nodejs用作Web服务器时,我遇到了一个小问题.

我的配置文件在下面链接,我只安装了nodejs和mongodb. IP框为10.10.56.101(在学校里我需要一个192.168.56.101以外的IP地址).

我尝试使用下面链接的小脚本访问nodejs服务器.该脚本仅侦听端口51160并回答确定".

首先我没有得到任何答案,经过搜索后,我发现我需要进行端口转发并使用iptable起作用(下面链接的命令在端口51160而不是8000上).

我以相同的配置重新安装了无业游民的机器,但我无法使机器正常工作.

我可以从无业游民的计算机中curl localhost:51160,但是从虚拟机外部什么也收不到.

文件:

解决方案

如果您可以从无业游民的计算机内部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 :

解决方案

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屋!

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