포트 3000 (내 레일 서버)과 포트 8888 (내 nodejs socket.io 서버)에 트래픽을 연결하기 위해 node-http-proxy를 사용하려고합니다. 나는 리버스 프록시 포트에 앉아 역할을하는 노드가-HTTP 프록시 사용하고 80Node-http-proxy를 socket.io와 함께 사용하려면?
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: CONFIG.RAILS_PORT,
}
});
var server = http.createServer(function(req, res) {
//
// Proxy normal HTTP requests
//
proxy.proxyRequest(req, res);
});
server.on('upgrade', function(req, socket, head) {
//
// Proxy websocket request to another port
//
console.log('inside upgrade');
proxy.proxyWebSocketRequest(req, socket, head, {
host: 'localhost',
port: CONFIG.NODEJS_PORT
});
});
server.listen(80);
var WrappedServer = require('./wrappedServer').WrappedServer
var singleton = new WrappedServer();
singleton.run(CONFIG.NODEJS_PORT, {'log level': 2});
(나는 거의 단지 노드-HTTP 프록시에서 README를 복사) 그리고이 내 클라이언트입니다 .js 브라우저에서.
var socket = io.connect('http://localhost', {'sync disconnect on unload': false});
아무 래도 io.connect가 nodejs 서버에 연결할 수 없습니다. 나는 io.connect에서이 반응을 얻고있다 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Action Controller: Exception caught</title>
<style>
body { background-color: #fff; color: #333; }
body, p, ol, ul, td {
font-family: helvetica, verdana, arial, sans-serif;
font-size: 13px;
line-height: 18px;
}
pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}
a { color: #000; }
a:visited { color: #666; }
a:hover { color: #fff; background-color:#000; }
</style>
</head>
<body>
<h1>Routing Error</h1>
<p><pre>No route matches [GET] "/socket.io/1"</pre></p>
</body>
</html>
내가 io.connect가 nodejs 서버에 연결을 얻을 수있는 방법 어떤 생각? 나는 io.connect를 트리거하여 서버에 도착하는 방법을 모른다. 업그레이드 블록.
감사합니다. !
나는 거의 같은 문제가있다. 이 문제에 대한 해결 방법을 찾았습니까? – Luc