我使用nodejitsu的node-http-proxy獲得了很好的結果。正如他們的自述中所述,他們似乎支持WebSockets。
舉例的WebSockets(從GitHub的自述拍攝):
var http = require('http'),
httpProxy = require('http-proxy');
//
// Create an instance of node-http-proxy
//
var proxy = new httpProxy.HttpProxy();
var server = http.createServer(function (req, res) {
//
// Proxy normal HTTP requests
//
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 8000
})
});
server.on('upgrade', function(req, socket, head) {
//
// Proxy websocket requests too
//
proxy.proxyWebSocketRequest(req, socket, head, {
host: 'localhost',
port: 8000
});
});
它的生產使用應該沒有問題,因爲它是用於nodejitsu.com。要將代理應用程序作爲守護程序運行,請考慮使用forever。
感謝這一個看起來不錯! – 2011-04-19 13:49:41
好吧,它工作正常!非常感謝你! – 2011-04-19 14:27:38