I have a single server running jetty as a web server. I run a proxy server at port 80 to decide whether a request is made for jetty or static file server using nodejs. My jetty is running at port 9000 and the other static file server is running at 9001. Here is my node proxy code;
var httpProxy = require('http-proxy');
var options = {
hostnameOnly : true,
router : {
'domain.com' : '127.0.0.1:9000',
'static.domain.com' : '127.0.0.1:9001'
}
}
var proxyServer = httpProxy.createServer(options).listen(80);
When I request a page from domain.com it gives me this error;
{ code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect' }
It is supposed to redirect the request to jetty but it just does not, couldn't figure out why.
In jetty config allowed ip for connections was the outer IP address of the server, I changed it to 127.0.0.1 and it worked.