8151170
据说linux跑node比较好,我根据新手入门的教程配置了node在虚拟机上(CentOS),然后根据以下教程写了第一个http server:https://github.com/alsotang/node-lessons/tree/master/lesson1 执行$ node app.js 显示 app is listening at port 8888
宿主机设置端口映射,主机的8088映射到虚拟机的8888,宿主机上的浏览器访问http://localhost:8088/ 请求超时了 作为对比,我开了centos自带的httpd,监听的是虚拟机的80端口,然后映射到主机的8080 ,宿主机上访问http://localhost:8080/ 可以!
继续作为比较,我在虚拟机上分别 $ nc -C 127.0.0.1 80 $ nc -C 127.0.0.1 8888 然后GET / 两个均有应答,访问8888 正常显示hello world, 但是只有宿主机不能访问node。。。这是为什么呢? P.S. iptables已经stop了。
还有个奇怪的地方,虚拟机下$ nc -C localhost 8888 会显示Ncat: Connection refused.