From 5098b1c6962863eab0003a2770f73279d46a1d03 Mon Sep 17 00:00:00 2001 From: liuzheng712 Date: Fri, 26 Feb 2016 22:48:07 +0800 Subject: [PATCH 1/3] fix(run_websocket.py): remote IP get bug when use nginx self.request.headers.get(X-Real-IP) will get real remote IP, self.request.remote_ip will get 127.0.0.1 ; if not it will git null, so need to use self.request.remote_ip for get the ip --- run_websocket.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run_websocket.py b/run_websocket.py index ddd724697..25a264b19 100755 --- a/run_websocket.py +++ b/run_websocket.py @@ -317,6 +317,8 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler): self.term = WebTty(self.user, asset, login_role, login_type='web') # self.term.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 self.ssh = self.term.get_connection() self.channel = self.ssh.invoke_shell(term='xterm') WebTerminalHandler.tasks.append(MyThread(target=self.forward_outbound)) From d67aab573d5323881a544de1f2b5159bda323543 Mon Sep 17 00:00:00 2001 From: liuzheng712 Date: Fri, 26 Feb 2016 22:59:17 +0800 Subject: [PATCH 2/3] fix: ip and port use jumpserver.conf to configure --- jumpserver.conf | 2 ++ jumpserver/settings.py | 2 ++ run_websocket.py | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jumpserver.conf b/jumpserver.conf index f184a246f..5db9cdd9d 100644 --- a/jumpserver.conf +++ b/jumpserver.conf @@ -2,6 +2,8 @@ url = http://192.168.244.129 key = 88aaaf7ffe3c6c04 log = debug +ip = 127.0.0.1 +port = 8080 [db] host = 127.0.0.1 diff --git a/jumpserver/settings.py b/jumpserver/settings.py index d1c8a8f40..eb418ad8e 100644 --- a/jumpserver/settings.py +++ b/jumpserver/settings.py @@ -42,6 +42,8 @@ KEY = config.get('base', 'key') URL = config.get('base', 'url') LOG_LEVEL = config.get('base', 'log') WEB_SOCKET_HOST = config.get('websocket', 'web_socket_host') +IP = config.get('base', 'ip') +PORT = config.get('base', 'port') # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ diff --git a/run_websocket.py b/run_websocket.py index ddd724697..af7a701d6 100755 --- a/run_websocket.py +++ b/run_websocket.py @@ -33,8 +33,9 @@ except ImportError: import json os.environ['DJANGO_SETTINGS_MODULE'] = 'jumpserver.settings' -define("port", default=3000, help="run on the given port", type=int) -define("host", default='0.0.0.0', help="run port on given host", type=str) +from jumpserver.settings import IP, PORT +define("port", default=PORT, help="run on the given port", type=int) +define("host", default=IP, help="run port on given host", type=str) def require_auth(role='user'): From ba8d808cd90741ee2305cbc6003f464bd80fb7c4 Mon Sep 17 00:00:00 2001 From: liuzheng712 Date: Fri, 26 Feb 2016 23:09:19 +0800 Subject: [PATCH 3/3] fix(service.sh): annotate django runserver --- service.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service.sh b/service.sh index d2a9d06c0..202096642 100755 --- a/service.sh +++ b/service.sh @@ -30,7 +30,7 @@ start() { echo "jumpserver is running..." success "$jump_start" else - daemon python $base_dir/manage.py runserver 0.0.0.0:80 &>> /tmp/jumpserver.log 2>&1 & +# daemon python $base_dir/manage.py runserver 0.0.0.0:80 &>> /tmp/jumpserver.log 2>&1 & daemon python $base_dir/manage.py crontab add &>> /tmp/jumpserver.log 2>&1 daemon python $base_dir/run_websocket.py &> /dev/null 2>&1 & sleep 4