From 77c7f8fb541951e6cd509da59e97f759e48e3f8c Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 1 Apr 2016 16:38:37 +0800 Subject: [PATCH] fix(web exec) Web execute command log didn't get the real ip if behind the lb proxy. fixed --- run_server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run_server.py b/run_server.py index 41f70fe25..c3b1ca963 100755 --- a/run_server.py +++ b/run_server.py @@ -233,7 +233,9 @@ class ExecHandler(tornado.websocket.WebSocketHandler): def open(self): logger.debug('Websocket: Open exec request') role_name = self.get_argument('role', 'sb') - self.remote_ip = self.request.remote_ip + self.term.remote_ip = self.request.headers.get("X-Real-IP") + if not self.term.remote_ip: + self.term.remote_ip = self.request.remote_ip logger.debug('Web执行命令: 请求系统用户 %s' % role_name) self.role = get_object(PermRole, name=role_name) self.perm = get_group_user_perm(self.user)