Default:
var T_TYPE_HTTP = 0,
T_TYPE_HTTPS = 1,
DEFAULT_PORT = 8001,
DEFAULT_WEB_PORT = 8002,
DEFAULT_WEBSOCKET_PORT = 8003,
DEFAULT_CONFIG_PORT = 8088,
DEFAULT_HOST = "localhost",
DEFAULT_TYPE = T_TYPE_HTTP;
✓ node bin.js -r reverse_proxy.js
rule file loaded :/opt/anyproxy/reverse_proxy.js
reverse proxy - assign an IP adress for some request
Anyproxy rules initialize finished, have fun!
GUI interface started at : http://66.35.69.94:8002/
Http proxy started at 66.35.69.94:8001
OK, but my app uses nodejs and socketio serving on port 49114 host 127.0.0.1, my reverse_proxy.js :
module.exports = {
summary:function(){
return "reverse proxy to localhost:49114";
},
replaceRequestOption : function(req,option){
var newOption = option;
newOption.hostname = "127.0.0.1";
newOption.port = "49114";
return newOption;
}
};
My chrome:
XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/?t=1424747292746".
socket.io.js:2371 WebSocket connection to 'ws://myhost.myname.com:8001/socket.io/1/websocket/anJVrPujLK3N8VuxcUgV' failed: Connection closed before receiving a handshake response
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747304818".
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747305107".
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747305390".
socket.io.js:2625 XHR finished loading: POST "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747305389".
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747305510".
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747325800".
socket.io.js:3012 GET http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747346094 net
Socket io fails from websocket to post
My node stdout:
received request to : myhost.myname.com:8001/
==>will forward to real server by proxy
received request to : myhost.myname.com:8001/socket.io/socket.io.js
==>will forward to real server by proxy
received request to : myhost.myname.com:8001/socket.io/1/?t=1424747671286
==>will forward to real server by proxy
received request to : myhost.myname.com:8001/favicon.ico
==>will forward to real server by proxy
received request to : myhost.myname.com:8001/socket.io/1/xhr-polling/u8iayXvF0VxGXZArcUgW?t=1424747681681
==>will forward to real server by proxy
I could reconfig nodejs app to connect to socketio on port 8003 but this is not necessary with haproxy:
frontend l
bind 1.2.3.4:8001
mode http
default_backend L
backend L
mode http
balance roundrobin
server static 127.0.0.1:49114 check inter 2000
AliBaba Can you help me use your cool app like this?
Rick