相关疑难解决方法(0)

如何在端口80上运行Node.js?

我的目标是在端口80上运行Node.js.这是因为我发现node.js被阻止某些不允许来自任何其他端口的流量的网络.

看来最好的方法是通过Node.js代理Apache.我曾尝试使用node-http-proxy来做到这一点,但我没有运气.

我正在使用的代码在这里:

var util = require('util'),
    http = require('http'),
    httpProxy = require('http-proxy');

httpProxy.createServer(9000, 'localhost').listen(80);

http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
  res.end();
}).listen(9000);
Run Code Online (Sandbox Code Playgroud)

但我不断收到端口80的错误"正在使用的地址".我一定是做错了.

如何使用node-http-proxy通过node.js代理Apache?这会让我在端口80上运行node.js吗?node-http-proxy是实现这一目标的最佳方式吗?

谢谢.

apache proxy websocket node.js

65
推荐指数
6
解决办法
7万
查看次数

标签 统计

apache ×1

node.js ×1

proxy ×1

websocket ×1