Einaros WS Server - Not Implemented Message

With Node JS + Einaros WS Server when I start a server and open the http:// serverIp:port on my browser, I get a "Not Implemented"

The module file WebSocketServer.js file looks like this:

  if (options.isDefinedAndNonNull('port')) {
    this._server = http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('Not implemented');
    });
    this._server.listen(options.value.port, options.value.host, callback);
    this._closeServer = function() { self._server.close(); };
  }

Rather than sending this Not implemented message, how can I simulate an unavailable or page doesn't exist ? I don't want to client to figure out the real serverIp/Port because it is actually working behind an haProxy load balancer.

The following 2 options come to my mind:

  • The best option would most likely be to block connections from someone else than the haProxy with your firewall.

  • If not possible, I would close the underlying socket with res.socket.destroy() to make the client believe that this server does not understand the protocol.

Update

Change this

this._server = http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Not implemented');
});

to this

this._server = http.createServer(function (req, res) {
  res.socket.destroy();
});

And it should work.