nodejs 没有收到转发端口上的请求

nodejs not receiving request on forwarded port

我正在尝试让我的路由器将对我的 noip 动态 dns 发出的请求转发到我有 nodjs 运行 的本地计算机,等待端口 14555 上的请求。

我设置了 noip dns,这样本地的 netcat 运行 确实会收到对端口 14555 的任何调用(即使用浏览器):

ncat -l -n -v -v -k -p 14555
Ncat: Version 5.59BETA1 ( http://nmap.org/ncat )
Ncat: Listening on 0.0.0.0:14555
Ncat: Connection from xxx.xxx.xxx.xxx:56409.
GET /socket.io/?EIO=3&transport=polling&t=1430939580269-4 HTTP/1.1
Host: someDomain.ddns.net:14555
Connection: keep-alive
...
NCAT DEBUG: Closing connection.
Ncat: Connection from 84.167.116.141:56411.

然而,尽管调用似乎通过了所有内容并到达了我的机器,但节点并没有听取它。它没有收到任何东西:

HTTP server listening at 0.0.0.0:14555/

我的接收服务器是这样配置的:

var self = this;
// Start the server
this.httpServer = http.createServer(function(req, res){ 
    // Send HTML headers and message
    res.writeHead(200,{ 'Content-Type': 'text/html' }); 
    res.end('<h1>Hello Socket Lover!</h1>');
});

//Listen on the port for HTTP requests
this.httpServer.listen(cfg.port, '0.0.0.0');

console.log('HTTP server listening at 0.0.0.0:' + cfg.port + '/');

P.S.: 这个问题最初是在 serverfault 上提出的,但我被要求移到这里。

*edit 1: 我做了另一个实验,用 nginx 监听 80 端口并转发 80 端口,结果相同:调用到达本地计算机的 80 端口,但 nginx 没有收到。

我最终找到了解决方案。这是我路由器的问题。

请参阅 my post on super user 以获得答案。