* secureProxy -> proxied in webSocket config

* Add support for X-Forwarded-For and X-Real-IP in WebSocket for remoteAddr
This commit is contained in:
Bryan Ashby 2017-06-01 18:48:14 -06:00
parent 385edc0953
commit ab8cb77f81
1 changed files with 6 additions and 5 deletions

View File

@ -25,7 +25,7 @@ const ModuleInfo = exports.moduleInfo = {
function WebSocketClient(ws, req, serverType) {
Object.defineProperty(this, 'isSecure', {
get : () => ('secure' === serverType || true === this.secureProxyConnection) ? true : false,
get : () => ('secure' === serverType || true === this.proxied) ? true : false,
});
//
@ -47,7 +47,8 @@ function WebSocketClient(ws, req, serverType) {
}
get remoteAddress() {
return req.connection.remoteAddress;
// Support X-Forwarded-For and X-Real-IP headers for proxied connections
return (this.proxied && (req.headers['x-forwarded-for'] || req.headers['x-real-ip'])) || req.connection.remoteAddress;
}
}(ws);
@ -75,11 +76,11 @@ function WebSocketClient(ws, req, serverType) {
// If the config allows it, look for 'x-forwarded-proto' as "https"
// to override |isSecure|
//
if(true === _.get(Config, 'loginServers.webSocket.secureProxy') &&
if(true === _.get(Config, 'loginServers.webSocket.proxied') &&
'https' === req.headers['x-forwarded-proto'])
{
Log.debug(`Assuming secure connection due to X-Forwarded-Proto of ${req.headers['x-forwarded-proto']}`);
this.secureProxyConnection = true;
Log.debug(`Assuming secure connection due to X-Forwarded-Proto of "${req.headers['x-forwarded-proto']}"`);
this.proxied = true;
}
// start handshake process