Jumpserver安装部署

总体介绍:

Jumpserver是全球首款完全开源的堡垒机,使用GNU GPL v2.0开源协议,是符合4A的专业运维审计系统;

Jumpserver使用Python/Django进行开发,遵循Web 2.0规范,配备了业界领先的Web Terminal解决方案,交互界面美观、用户体验好;

Jumpserver采纳分布式架构,支持多机房跨区域部署,中心节点提高API,个机房部署登录节点,可横向扩展、无并发访问限制;

Jumpserver现已支持管理SSH、Telnet、RDP、VNC协议资产。

特色优势:

  • 开源:零门槛,线上快速获取和安装;
  • 分布式:轻松支持大规模并发访问;
  • 无插件:仅需浏览器,极致的Web Terminal 使用体验;
  • 多云支持:一套系统,同时管理不同云上面的资产;
  • 云端存储:审计录像云端存储,永不丢失;
  • 多租户:一套系统,多个子公司和部门同时使用。

功能列表:

身份认证
Authentication
登录认证 资源统一登录与认证
LDAP/AD 认证
RADIUS 认证
OpenID 认证(实现单点登录)
CAS 认证 (实现单点登录)
MFA认证 MFA 二次认证(Google Authenticator)
RADIUS 二次认证
登录复核(X-PACK) 用户登录行为受管理员的监管与控制
账号管理
Account
集中账号 管理用户管理
系统用户管理
统一密码 资产密码托管
自动生成密码
自动推送密码
密码过期设置
批量改密(X-PACK) 定期批量改密
多种密码策略
多云纳管(X-PACK) 对私有云、公有云资产自动统一纳管
收集用户(X-PACK) 自定义任务定期收集主机用户
密码匣子(X-PACK) 统一对资产主机的用户密码进行查看、更新、测试操作
授权控制
Authorization
多维授权 对用户、用户组、资产、资产节点、应用以及系统用户进行授权
资产授权 资产以树状结构进行展示
资产和节点均可灵活授权
节点内资产自动继承授权
子节点自动继承父节点授权
应用授权 实现更细粒度的应用级授权
MySQL 数据库应用、RemoteApp 远程应用(X-PACK)
动作授权 实现对授权资产的文件上传、下载以及连接动作的控制
时间授权 实现对授权资源使用时间段的限制
特权指令 实现对特权指令的使用(支持黑白名单)
命令过滤 实现对授权系统用户所执行的命令进行控制
文件传输 SFTP 文件上传/下载
文件管理 实现 Web SFTP 文件管理
工单管理(X-PACK) 支持对用户登录请求行为进行控制
组织管理(X-PACK) 实现多租户管理与权限隔离
安全审计
Audit
操作审计 用户操作行为审计
会话审计 在线会话内容审计
历史会话内容审计
录像审计 支持对 Linux、Windows 等资产操作的录像进行回放审计
支持对 RemoteApp(X-PACK)、MySQL 等应用操作的录像进行回放审计
指令审计 支持对资产和应用等操作的命令进行审计
文件传输 可对文件的上传、下载记录进行审计

安装环境准备:

1、jumpserver运行环境:

硬件配置:2C4G,50GSSD(最低)

操作系统centos 7.6

Python = 3.6.x

Mysql Server ≥ 5.6

Mariadb Server ≥ 5.5.56

Redis

2、关闭防火墙与selinux

[root@jumpserver centos]# systemctl stop firewalld
[root@jumpserver centos]# systemctl disable firewalld
[root@jumpserver centos]# setenforce 0

3、准备Python3和Python虚拟环境

最新的jumpserver环境依赖于Python3

安装依赖包:

[root@jumpserver centos]# yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel opel-release git
# 下载python3 编译 安装
[root@jumpserver centos]# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
[root@jumpserver centos]# tar xf Python-3.6.1.tar.xz && cd Python-3.6.1
[root@jumpserver centos]# ./configure && make && make install

 建立Python虚拟环境:

CentOS 7 自带的是python2,而yum等工具依赖原来单独python,为了不扰乱原来等环境我们来使用Python虚拟环境

[root@jumpserver ~]# cd /opt/
[root@jumpserver opt]# python3 -m venv py3
[root@jumpserver opt]# source /opt/py3/bin/activate
# 看到下面的提示符代表成功,以后运行jumpserver都要先运行以上source命令,以下所有命令均在虚拟环境中运行
(py3) [root@jumpserver opt]#  

自动载入python虚拟环境配置,此项仅为懒癌晚期的人员使用,防止运行Jumpserver时忘记载入Python虚拟环境导致程序无法运行。使用autoenv

(py3) [root@jumpserver opt]# git clone git://github.com/kennethreitz/autoenv.git
(py3) [root@jumpserver opt]# echo 'source /opt/autoenv/activate.sh' >> ~/.bashrc
(py3) [root@jumpserver opt]# source ~/.bashrc

安装Jumpserver

下载或clone项目

下载:

(py3) [root@jumpserver opt]#  wget -O jumpserver.tar.gz https://github.com/jumpserver/jumpserver/archive/2.0.1.tar.gz
(py3) [root@jumpserver opt]# tar xf jumpserver.tar.gz
(py3) [root@jumpserver opt]# mv jumpserver-2.0.1 jumpserver

clone项目:

(py3) [root@jumpserver opt]# git clone https://github.com/jumpserver/jumpserver.git && cd jumpserver 
(py3) [root@jumpserver jumpserver]# echo "source /opt/py3/bin/activate" > /opt/jumpserver/.env   #进入jumpserver目录时将自动载入python虚拟环境

安装编译环境依赖:

(py3) [root@jumpserver jumpserver]# cd requirements/
# 首次进入 jumpserver 文件夹会有提示,按 y 即可
Are you sure you want to allow this? (y/N) y
# 安装 依赖RPM包
(py3) [root@jumpserver requirements]# yum -y install $(cat rpm_requirements.txt)
# 安装Python库依赖
(py3) [root@jumpserver requirements]# pip install -r requirements.txt 

安装Redis,Jumpserver使用Redis做cache和celery broke

(py3) [root@jumpserver requirements]# yum -y install redis
(py3) [root@jumpserver requirements]# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
(py3) [root@jumpserver requirements]# systemctl start redis

安装Mysql:

(py3) [root@jumpserver requirements]# yum -y install mariadb mariadb-devel mariadb-server
(py3) [root@jumpserver requirements]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
(py3) [root@jumpserver requirements]# systemctl start mariadb 

创建数据库Jumpserver并授权:

(py3) [root@jumpserver requirements]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 70762
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> create database jumpserver default charset 'utf8';
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on jumpserver.* to 'jumpserver'@'%' identified by 'somepassword';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

  

修改Jumpserver配置文件:

(py3) [root@jumpserver jumpserver]# cp config_example.yml config.yml
(py3) [root@jumpserver jumpserver]# vim config.yml

  

# SECURITY WARNING: keep the secret key used in production secret!
# 加密秘钥 生产环境中请修改为随机字符串,请勿外泄, 可使用命令生成
# cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 49;echo
SECRET_KEY: W5Ic3fMXNZ0p5RIy5DhJYJllppTfcfkW8Yuf94VBMfpcssbfu

# SECURITY WARNING: keep the bootstrap token used in production secret!
# 预共享Token coco和guacamole用来注册服务账号,不在使用原来的注册接受机制
BOOTSTRAP_TOKEN: 123qweasdzxc

# Development env open this, when error occur display the full process track, Production disable it
# DEBUG 模式 开启DEBUG后遇到错误时可以看到更多日志
DEBUG: false

# DEBUG, INFO, WARNING, ERROR, CRITICAL can set. See https://docs.djangoproject.com/en/1.10/topics/logging/
# 日志级别
LOG_LEVEL: ERROR
# LOG_DIR:

# Session expiration setting, Default 24 hour, Also set expired on on browser close
# 浏览器Session过期时间,默认24小时, 也可以设置浏览器关闭则过期
# SESSION_COOKIE_AGE: 86400
SESSION_EXPIRE_AT_BROWSER_CLOSE: true

# Database setting, Support sqlite3, mysql, postgres ....
# 数据库设置
# See https://docs.djangoproject.com/en/1.10/ref/settings/#databases

# SQLite setting:
# 使用单文件sqlite数据库
# DB_ENGINE: sqlite3
# DB_NAME:

# MySQL or postgres setting like:
# 使用Mysql作为数据库
DB_ENGINE: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: jumpserver
DB_PASSWORD: rBi41SrDqlX4zsx9e1L0cqTP
DB_NAME: jumpserver

# When Django start it will bind this host and port
# ./manage.py runserver 127.0.0.1:8080
# 运行时绑定端口
HTTP_BIND_HOST: 0.0.0.0
HTTP_LISTEN_PORT: 8080
WS_LISTEN_PORT: 8070

# Use Redis as broker for celery and web socket
# Redis配置
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
REDIS_PASSWORD: ZhYnLrodpmPncovxJTnRyiBs
# REDIS_DB_CELERY: 3
# REDIS_DB_CACHE: 4

# Use OpenID authorization
# 使用OpenID 来进行认证设置
# BASE_SITE_URL: http://localhost:8080
# AUTH_OPENID: false  # True or False
# AUTH_OPENID_SERVER_URL: https://openid-auth-server.com/
# AUTH_OPENID_REALM_NAME: realm-name
# AUTH_OPENID_CLIENT_ID: client-id
# AUTH_OPENID_CLIENT_SECRET: client-secret
# AUTH_OPENID_IGNORE_SSL_VERIFICATION: True
# AUTH_OPENID_SHARE_SESSION: True

# Use Radius authorization
# 使用Radius来认证
# AUTH_RADIUS: false
# RADIUS_SERVER: localhost
# RADIUS_PORT: 1812
# RADIUS_SECRET:

# CAS 配置
# AUTH_CAS': False,
# CAS_SERVER_URL': "http://host/cas/",
# CAS_ROOT_PROXIED_AS': 'http://jumpserver-host:port',  
# CAS_LOGOUT_COMPLETELY': True,
# CAS_VERSION': 3,

# LDAP/AD settings
# LDAP 搜索分页数量
# AUTH_LDAP_SEARCH_PAGED_SIZE: 1000
#
# 定时同步用户
# 启用 / 禁用
# AUTH_LDAP_SYNC_IS_PERIODIC: True
# 同步间隔 (单位: 时) (优先)
# AUTH_LDAP_SYNC_INTERVAL: 12
# Crontab 表达式
# AUTH_LDAP_SYNC_CRONTAB: * 6 * * *
#
# LDAP 用户登录时仅允许在用户列表中的用户执行 LDAP Server 认证
# AUTH_LDAP_USER_LOGIN_ONLY_IN_USERS: False
#
# LDAP 认证时如果日志中出现以下信息将参数设置为 0 (详情参见:https://www.python-ldap.org/en/latest/faq.html)
# In order to perform this operation a successful bind must be completed on the connection
# AUTH_LDAP_OPTIONS_OPT_REFERRALS: -1

# OTP settings
# OTP/MFA 配置
# OTP_VALID_WINDOW: 0
# OTP_ISSUER_NAME: Jumpserver

# Perm show single asset to ungrouped node
# 是否把未授权节点资产放入到 未分组 节点中
# PERM_SINGLE_ASSET_TO_UNGROUP_NODE: false
#
# 启用定时任务
# PERIOD_TASK_ENABLE: True
#
# 启用二次复合认证配置
# LOGIN_CONFIRM_ENABLE: False
#
# Windows 登录跳过手动输入密码
WINDOWS_SKIP_ALL_MANUAL_PASSWORD: True

# Default using Config settings, you can write if/else for different env

class DevelopmentConfig(Config):    
DEBUG = True    
DB_ENGINE = 'mysql'    
DB_HOST = '127.0.0.1'    
DB_PORT = 3306    
DB_USER = 'jumpserver'    
DB_PASSWORD = '123456'    
DB_NAME = 'jumpserver'config = DevelopmentConfig()
# 增加上面的内容(一定要添加class这段,不然数据库初始化数据的时候会报错) 

生成数据库表结构和初始化数据:

(py3) [root@jumpserver jumpserver]# cd /opt/jumpserver/utils
(py3) [root@jumpserver utils]# bash make_migrations.sh
2018-05-09 13:51:48 [signals_handler DEBUG] Receive django ready signal
2018-05-09 13:51:48 [signals_handler DEBUG]   - fresh all settings
Migrations for 'assets': 
/opt/jumpserver/apps/assets/migrations/0002_auto_20180509_1351.py
--------------------中间省略
Running migrations:  
Applying assets.0001_initial... OK  
Applying assets.0002_auto_20180509_1351... OK  
Applying audits.0001_initial... OK  
Applying contenttypes.0001_initial... OK  
Applying contenttypes.0002_remove_content_type_name... OK 
Applying auth.0001_initial... OK  
Applying auth.0002_alter_permission_name_max_length... OK 
Applying auth.0003_alter_user_email_max_length... OK 
Applying auth.0004_alter_user_username_opts... OK  
Applying auth.0005_alter_user_last_login_null... OK 
Applying auth.0006_require_contenttypes_0002... OK 
Applying auth.0007_alter_validators_add_error_messages... OK  
Applying auth.0008_alter_user_username_max_length... OK 
Applying captcha.0001_initial... OK  
Applying common.0001_initial... OK  
Applying django_celery_beat.0001_initial... OK  
Applying django_celery_beat.0002_auto_20161118_0346... OK
Applying django_celery_beat.0003_auto_20161209_0049... OK 
Applying django_celery_beat.0004_auto_20170221_0000... OK
Applying django_celery_beat.0005_add_solarschedule_events_choices... OK  
Applying django_celery_beat.0006_auto_20180210_1226... OK
Applying ops.0001_initial... OK  
Applying ops.0002_celerytask... OK  
Applying users.0001_initial... OK  
Applying users.0002_auto_20171225_1157... OK  
Applying users.0003_auto_20180509_1351... OK  
Applying perms.0001_initial... OK  
Applying perms.0002_auto_20180509_1351... OK  
Applying sessions.0001_initial... OK  
Applying terminal.0001_initial... OK  
Applying terminal.0002_auto_20180509_1351... OK 

运行Jumpserver:

(py3) [root@jumpserver jumpserver]# ./jms start  -d
# 新版本更新了运行脚本。使用方式 ./jms start|stop|status|restart all  -d 后台运行

部署KoKo组件

(py3) [root@jumpserver opt]# wget https://github.com/jumpserver/koko/releases/download/2.0.1/koko-master-linux-amd64.tar.gz
(py3) [root@jumpserver opt]# tar -xf koko-master-linux-amd64.tar.gz
(py3) [root@jumpserver opt]# chown -R root:root kokodir
(py3) [root@jumpserver opt]# cd kokodir
(py3) [root@jumpserver opt]# cp config_example.yml config.yml
(py3) [root@jumpserver opt]# vi config.yml

# BOOTSTRAP_TOKEN 需要从 jumpserver/config.yml 里面获取, 保证一致
# 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复
# NAME: {{ Hostname }}
NAME: koko

# Jumpserver项目的url, api请求注册会使用
CORE_HOST: http://127.0.0.1:8080

# Bootstrap Token, 预共享秘钥, 用来注册coco使用的service account和terminal
# 请和jumpserver 配置文件中保持一致,注册完成后可以删除
BOOTSTRAP_TOKEN: 123qweasdzxc

# 启动时绑定的ip, 默认 0.0.0.0
# BIND_HOST: 0.0.0.0

# 监听的SSH端口号, 默认2222
# SSHD_PORT: 2222

# 监听的HTTP/WS端口号,默认5000
HTTPD_PORT: 5000

# 项目使用的ACCESS KEY, 默认会注册,并保存到 ACCESS_KEY_STORE中,
# 如果有需求, 可以写到配置文件中, 格式 access_key_id:access_key_secret
ACCESS_KEY: none

# ACCESS KEY 保存的地址, 默认注册后会保存到该文件中
# ACCESS_KEY_FILE: data/keys/.access_key

# 设置日志级别 [DEBUG, INFO, WARN, ERROR, FATAL, CRITICAL]
# LOG_LEVEL: INFO
LOG_LEVEL: ERROR

# SSH连接超时时间 (default 15 seconds)
# SSH_TIMEOUT: 15

# 语言 [en,zh]
# LANG: zh

# SFTP的根目录, 可选 /tmp, Home其他自定义目录
# SFTP_ROOT: /tmp

# SFTP是否显示隐藏文件
# SFTP_SHOW_HIDDEN_FILE: false

# 是否复用和用户后端资产已建立的连接(用户不会复用其他用户的连接)
# REUSE_CONNECTION: true

# 资产加载策略, 可根据资产规模自行调整. 默认异步加载资产, 异步搜索分页; 如果为all, 则资产全部加载, 本地搜索分页.
# ASSET_LOAD_POLICY:

# zip压缩的最大额度 (单位: M)
# ZIP_MAX_SIZE: 1024M

# zip压缩存放的临时目录 /tmp
# ZIP_TMP_PATH: /tmp

# 向 SSH Client 连接发送心跳的时间间隔 (单位: 秒),默认为30, 0则表示不发送
# CLIENT_ALIVE_INTERVAL: 30

# 向资产发送心跳包的重试次数,默认为3
# RETRY_ALIVE_COUNT_MAX: 3

# 会话共享使用的类型 [local, redis], 默认local
# SHARE_ROOM_TYPE: local
SHARE_ROOM_TYPE: redis
# Redis配置
 REDIS_HOST: 127.0.0.1
 REDIS_PORT: 6379
 REDIS_PASSWORD:
# REDIS_CLUSTERS:
REDIS_DB_ROOM:6

运行koko

(py3) [root@jumpserver kokodir]# ./koko -d (-d参数在后台运行)

部署Guacamole组件

(py3) [root@jumpserver opt]# wget -O /opt/guacamole.tar.gz https://github.com/jumpserver/docker-guacamole/archive/2.0.2.tar.gz
(py3) [root@jumpserver opt]# tar -xf guacamole.tar.gz
(py3) [root@jumpserver opt]# mv docker-guacamole-2.0.2 guacamole
(py3) [root@jumpserver opt]# cd guacamole
(py3) [root@jumpserver guacamole]# tar -xf guacamole-server-1.2.0.tar.gz
(py3) [root@jumpserver guacamole]# tar -xf ssh-forward.tar.gz -C /bin/
(py3) [root@jumpserver guacamole]# chmod +x /bin/ssh-forward
(py3) [root@jumpserver guacamole]# cd guacamole-server-1.0.0
(py3) [root@jumpserver guacamole-server-1.0.0]# ./configure --with-init-dir=/etc/init.d
(py3) [root@jumpserver guacamole-server-1.0.0]# make && make install
# 在当前环境配置Java
(py3) [root@jumpserver guacamole-server-1.0.0]# yum install -y java-1.8.0-openjdk
(py3) [root@jumpserver ~]# mkdir -p /config/guacamole /config/guacamole/extensions /config/guacamole/record /config/guacamole/drive
(py3) [root@jumpserver ~]# chown daemon:daemon /config/guacamole/record /config/guacamole/drive
(py3) [root@jumpserver ~]# cd /config
(py3) [root@jumpserver config]# wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.36/bin/apache-tomcat-9.0.36.tar.gz
(py3) [root@jumpserver config]# tar -xf apache-tomcat-9.0.36.tar.gz 
(py3) [root@jumpserver config]# mv apache-tomcat-9.0.36 tomcat9
(py3) [root@jumpserver config]# rm -rf /config/tomcat9/webapps/*
(py3) [root@jumpserver config]# sed -i 's/Connector port="8080"/Connector port="8081"/g' /config/tomcat9/conf/server.xml
(py3) [root@jumpserver config]# echo "java.util.logging.ConsoleHandler.encoding = UTF-8" >> /config/tomcat9/conf/logging.properties
(py3) [root@jumpserver config]# ln -sf /opt/guacamole/guacamole-1.0.0.war /config/tomcat9/webapps/ROOT.war
(py3) [root@jumpserver config]# ln -sf /opt/guacamole/guacamole-auth-jumpserver-1.0.0.jar /config/guacamole/extensions/guacamole-auth-jumpserver-1.0.0.jar
(py3) [root@jumpserver config]# ln -sf /opt/guacamole/root/app/guacamole/guacamole.properties /config/guacamole/guacamole.properties  

设置Guacamole环境:

(py3) [root@jumpserver ~]# vim ~/.bashrc
# 在末尾添加下面几行
export JUMPSERVER_SERVER=http://127.0.0.1:8080
export BOOTSTRAP_TOKEN=123qweasdzxc
export JUMPSERVER_KEY_DIR=/config/guacamole/keys
export GUACAMOLE_HOME=/config/guacamole
export GUACAMOLE_LOG_LEVEL=ERROR
export JUMPSERVER_ENABLE_DRIVE=true  

启动Guacamole:

(py3) [root@jumpserver ~]# /etc/init.d/guacd start
(py3) [root@jumpserver ~]# sh /config/tomcat9/bin/startup.sh

下载Lina组件

(py3) [root@jumpserver opt]# wget https://github.com/jumpserver/lina/releases/download/2.0.1/lina.tar.gz
(py3) [root@jumpserver opt]# tar -xf lina.tar.gz
(py3) [root@jumpserver opt]# chown -R root:root lina

下载Luna组件

(py3) [root@jumpserver opt]# wget https://github.com/jumpserver/luna/releases/download/2.0.1/luna.tar.gz
(py3) [root@jumpserver opt]# tar -xf luna.tar.gz
(py3) [root@jumpserver opt]# chown -R nginx:nginx luna

配置Nginx整合各组件:

# yum 安装nginx
(py3) [root@jumpserver ~]# yum -y install nginx
# 添加jumpserver配置文件
(py3) [root@jumpserver ~]# cd /etc/nginx
(py3) [root@jumpserver ~]# mkdir vhost
(py3) [root@jumpserver ~]# vim nginx.conf
#添加 include
include /etc/nginx/vhost/*.conf;
(py3) [root@jumpserver ~]# vim /etc/nginx/vhost/jumpserver.conf
server {
    listen 80;
    server_name jumpserver.xxx.com;
    root        /opt/lina;
    index       index.html;
    access_log /var/log/nginx/jumpserver-access.log main;
    error_log  /var/log/nginx/jumpserver-error.log error;
    client_max_body_size 100m;  # 录像及文件上传大小限制

    location /ui/ {
        try_files $uri / /index.html;
        alias /opt/lina/;
    }

    location /luna/ {
        try_files $uri / /index.html;
        alias /opt/luna/;  # luna 路径, 如果修改安装目录, 此处需要修改
    }

    location /media/ {
        add_header Content-Encoding gzip;
        root /opt/jumpserver/data/;  # 录像位置, 如果修改安装目录, 此处需要修改
    }

    location /static/ {
        root /opt/jumpserver/data/;  # 静态资源, 如果修改安装目录, 此处需要修改
    }

    location /koko/ {
        proxy_pass       http://localhost:5000;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        access_log off;
    }

    location /guacamole/ {
        proxy_pass       http://localhost:8081/;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $http_connection;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        access_log off;
    }

    location /ws/ {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:8070;
        proxy_http_version 1.1;
        proxy_buffering off;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location /api/ {
        proxy_pass http://localhost:8080;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /core/ {
        proxy_pass http://localhost:8080;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location / {
        rewrite ^/(.*)$ /ui/$1 last;
    }
}

启动nginx:

(py3) [root@jumpserver vhost]# nginx -t
(py3) [root@jumpserver vhost]# systemctl enable nginx
(py3) [root@jumpserver vhost]# systemctl start nginx

  

开始使用Jumpserver

浏览器访问 http://jumpserver.xxx.com/ 默认账号:admin 密码:admin

  

 

  

原文地址:https://www.cnblogs.com/winnerREN/p/13260194.html