Jumpserver系統架構簡述
Jumpserver堡壘機平臺架構簡述
Jumpserver堡壘機平臺基本架構如下圖:
這裏可以看出,運維及開發人員僅僅需要通過和堡壘機系統進行交互,通過堡壘機系統即可訪問服務器。與傳統運維相比,堡壘機系統僅僅在人和機器之間加了一層類似於代理的服務,平臺對於運維及開發人員相當於透明的,但可以將所有的操作數
據流都通過堡壘機系統進行授權及審計。其中coco支持設置SSH用戶黑名單和白名單功能,黑名單優先級更高。若把某SSH用戶加入到黑名單意味着阻止該用戶登錄,若把某SSH用戶加入到白名單意味着允許該用戶登錄。若某SSH用戶既在黑名單,也在白名單,由於黑名單優先級更高,意味着阻止該SSH用戶登錄。若某SSH用戶即沒在黑名單,也沒在白名單,意味着該SSH用戶無法登錄。
橫向擴展
Jumpserver堡壘機的架構設計中,是支持橫向擴展的,理論上在物理設備允許的條件下是無限擴展的,橫向擴展我們並不收取額外費用。
混合雲部署
由於Jumpserver堡壘機是一款軟件堡壘機解決方案,故此在設計上支持混合雲架構的部署,具體實施方案依客戶需求而定。
高可用方案
Jumpserver堡壘機提供幾類高可用的方案,具體可以在實施上根據客戶的需求進行設計部署。
支持OpenID
登錄支持OpenID,實現單點登錄。對接CMP keyclock,登錄時跳轉的OpenID登陸頁面,成功後跳轉到Jumpserver,成功統一了認證。
Docker版本: 在 config_docker.py 中添加以下配置信息。
開源版本:在 config_example.py 中有OpenID的配置信息demo。
儀表盤
在Jumpserver的儀表盤,管理員可以清楚的看到資源數、用戶數、登陸情況、資源使用情況等,界面友好且直觀,並且支持中英文切換。
Jumpserver-2.5.3 分佈式部署
本文檔不應該直接使用在生產環境
說明
本文檔需要非常專業的能力來解決一些集羣問題,如集羣崩潰 集羣分離 集羣擴展 lvs 負載均衡策略 故障排查 以及 集羣組件存活檢測機制等。在這些問題上你可能無法獲得 JumpServer 額外的技術支持。
環境說明
- 系統: CentOS 7
- NFS IP: 192.168.100.99
- mysql IP: 192.168.100.10
- Redis ip: 192.168.100.20
- Core IP: 192.168.100.30 192.168.100.31
- koko IP: 192.168.100.40 192.168.100.41
- Guacamole IP: 192.168.100.50 192.168.100.51
- Tengine IP: 192.168.100.100
- Tengine 作爲Nginx的替代品,作用於反向代理。
- Coco(koko):Coco爲 SSH Server 和 Web Terminal Server。用戶可以通過使用自己的賬戶登錄 SSH 或者 Web Terminal直接訪問被授權的資產。不需要知道服務器的賬戶和密碼,現在 Coco 已經被 koko 取代。
- Luna:luna 爲 Web Terminal Server 前端頁面,用戶使用 Web Terminal 方式登錄時所需要的插件。
- Guacamole:Guacamole 爲 Windows 組件,用戶可以通過 Web Terminal 來連接 Windows 資產(暫時只能通過 Web Terminal來訪問)
- Core:現指 Jumpserver 管理後臺,是核心組件, 使用 Django Class Based View 風格開發,支持 Restful API。
安全說明
- ssh、telnet 協議資產的防火牆設置允許 koko 與 core 訪問
- rdp、vnc 協議資產的防火牆設置允許 guacamole 與 core 訪問
其他
- 最終用戶都是通過 Tengine 反向代理訪問(也可以使用nginx)
- 負載均衡模式, 七層使用 session_sticky, 四層用 least_conn
- jumpserver/data 目錄需要同步
- koko 需要使用同一個 redis
生產集羣部署建議
- 你也可以使用如 NetScaler 類似的硬件或者軟件來進行負載均衡策略,請處理好 session 問題。
- 在生產環境中,你應該替換 nfs 爲更強大的分佈式文件系統,如: Ceph
- 如果你的設備很多使用人數也很多,你應該部署分佈式關係型數據庫
- 你應該部署多個獨立的 Redis 負載均衡進行容錯(當前版本的 JumpServer 還不支持 Redis Cluster)
- Tengine RPM 使用 wojiushixiaobai 維護的一個 rpm 包,在生產環境中你應該自行編譯
生產安全建議
Jumpserver 對外需要開放 80 和 2222 端口,如果你配置了 ssl 還需要開放 443 端口, 8080 端口開放給 koko 和 guacamole 組件訪問
- JumpServer 所在服務器操作系統應該升級到最新
- JumpServer 依賴的軟件升級到最新版本
- 服務器、數據庫、redis 等依賴組件請勿使用弱口令密碼
- 不推薦關閉 firewalld 和 selinux
- 只開放必要的端口,必要的話請通過 vpn 或者 sslvpn 訪問 JumpServer
- 如果必須開放到外網使用,你應該部署 web 應用防火牆做安全過濾
- 請部署 ssl 證書通過 https 協議來訪問 JumpServer
- JumpServer 不要使用弱口令密碼,應立即改掉默認的 admin 密碼
- 推薦開啓 MFA 功能,避免因密碼泄露導致的安全問題
NFS 部署
環境
- 系統: CentOS 7
- IP: 192.168.100.99
+----------+------------+-----------------+------------------------+
| Protocol | ServerName | IP | Used By |
+==========+============+=================+========================+
| TCP | NFS | 192.168.100.99 | Core, Tengine |
+----------+------------+-----------------+------------------------+
安裝步驟
安裝 epel 庫
yum upgrade -y
yum -y install epel-release
配置防火牆
firewall-cmd --add-service=nfs --permanent --zone=public
firewall-cmd --add-service=mountd --permanent --zone=public
firewall-cmd --add-service=rpc-bind --permanent --zone=public
firewall-cmd --reload
生產環境應該使用更嚴格的方式
安裝 nfs-server
yum -y install nfs-utils rpcbind
systemctl enable rpcbind nfs-server nfs-lock nfs-idmap
systemctl start rpcbind nfs-server nfs-lock nfs-idmap
創建 NFS 共享目錄
mkdir /data
此共享目錄存放 JumpServer 的錄像及任務結果
設置 NFS 訪問權限
vi /etc/exports
/data 192.168.100.*(rw,sync,no_root_squash)
/data 是剛纔創建的將被共享的目錄, 192.168.100._ 表示整個 192.168.100._ 的資產都有括號裏面的權限
也可以寫具體的授權對象 /data 192.168.100.30(rw,sync,no_root_squash) 192.168.100.31(rw,sync,no_root_squash)
使 exports 生效
exportfs -a
mysql 部署
環境
- 系統: CentOS 7
- 服務: MySQL Server
+----------+------------+-----------------+---------------+------------------------+
| Protocol | ServerName | IP | Port | Used By |
+==========+============+=================+===============+========================+
| TCP | MySQL | 192.168.100.10 | 3306 | Core |
+----------+------------+-----------------+---------------+------------------------+
安裝步驟
安裝 epel 庫
yum upgrade -y
yum -y install epel-release wget
配置防火牆
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.0/24" port protocol="tcp" port="3306" accept"
firewall-cmd --reload
生產環境請勿授權整個網段, 請根據實際情況修改
安裝 mysql
yum -y localinstall http://mirrors.ustc.edu.cn/mysql-repo/mysql57-community-release-el7.rpm
yum -y install mysql-community-server
sed -i "s@--initialize @--initialize-insecure @g" /usr/bin/mysqld_pre_systemd
啓動 mysql
systemctl enable mysqld
systemctl start mysqld
創建數據庫及授權
mysql -uroot
create database jumpserver default charset 'utf8' collate 'utf8_bin';
set global validate_password_policy=LOW;
grant all on jumpserver.* to 'jumpserver'@'192.168.100.%' identified by 'weakPassword';
flush privileges;
數據庫密碼應該採用更安全的密碼
Redis 部署
環境
- 系統: CentOS 7
- IP: 192.168.100.20
+----------+------------+-----------------+---------------+------------------------+
| Protocol | ServerName | IP | Port | Used By |
+==========+============+=================+===============+========================+
| TCP | Redis | 192.168.100.20 | 6379 | Core |
+----------+------------+-----------------+---------------+------------------------+
注意: Redis 的數據庫 3,4,5 被 Core 使用, 6 被 Koko 使用
安裝步驟
安裝 epel 庫
yum upgrade -y
yum -y install epel-release wget
配置防火牆
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.0/24" port protocol="tcp" port="6379" accept"
firewall-cmd --reload
生產環境應該最小化授權
安裝 redis
yum install -y install epel-release
yum install -y redis
修改配置文件
vi /etc/redis.conf
...
# bind 127.0.0.1 # 註釋這行, 新增如下內容
bind 0.0.0.0
requirepass weakPassword # redis 連接密碼
maxmemory-policy allkeys-lru # 清理策略, 優先移除最近未使用的key
...
啓動 redis
systemctl start redis
systemctl enable redis
Core 部署
環境
- 系統: CentOS 7
- IP: 192.168.100.30
+----------+------------+-----------------+---------------+-------------------------+
| Protocol | ServerName | IP | Port | Used By |
+==========+============+=================+===============+=========================+
| TCP | Core | 192.168.100.30 | 8070,8080 | Tengine |
+----------+------------+-----------------+---------------+-------------------------+
| TCP | Core | 192.168.100.31 | 8070,8080 | Tengine |
+----------+------------+-----------------+---------------+-------------------------+
安裝步驟
安裝 epel 庫
yum upgrade -y
yum -y install epel-release wget
配置防火牆
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.100" port protocol="tcp" port="8080" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.100" port protocol="tcp" port="8070" accept"
firewall-cmd --reload
setsebool -P httpd_can_network_connect 1
192.168.100.100 爲 tengine 服務器 ip, 請根據實際情況修改
安裝 git
yum -y install gcc git
安裝 python3.6
yum -y install python36 python36-devel
配置 py3 虛擬環境
python3.6 -m venv /opt/py3
source /opt/py3/bin/activate
下載 core
cd /opt && \
wget https://github.com/jumpserver/jumpserver/releases/download/v2.5.3/jumpserver-v2.5.3.tar.gz
tar xf jumpserver-v2.5.3.tar.gz
mv jumpserver-v2.5.3 jumpserver
安裝 rpm 依賴包
yum -y install $(cat /opt/jumpserver/requirements/rpm_requirements.txt)
安裝 python 依賴
pip install -r /opt/jumpserver/requirements/requirements.txt
修改配置文件
cd /opt/jumpserver
cp config_example.yml config.yml
SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`
echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc
BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`
echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc
sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /opt/jumpserver/config.yml
sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/jumpserver/config.yml
sed -i "s/# DEBUG: true/DEBUG: false/g" /opt/jumpserver/config.yml
sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /opt/jumpserver/config.yml
sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /opt/jumpserver/config.yml
echo -e "\033[31m 你的SECRET_KEY是 $SECRET_KEY \033[0m"
echo -e "\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m"
注意不能使用純數字字符串, BOOTSTRAP_TOKEN 給其他組件使用, redis 信息要給 koko 使用
以下模板僅供參考
vi 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: zxffNymGjP79j6BN
# 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: 192.168.100.10
DB_PORT: 3306
DB_USER: jumpserver
DB_PASSWORD: weakPassword
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: 192.168.100.20
REDIS_PORT: 6379
REDIS_PASSWORD: weakPassword
# 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
掛載 nfs
yum -y install nfs-utils
showmount -e 192.168.100.99
mount -t nfs 192.168.100.99:/data /opt/jumpserver/data
192.168.100.99 爲 nfs 服務器 ip, 請根據實際情況更改
vi /etc/fstab
192.168.100.99:/data /opt/jumpserver/data nfs defaults 0 0
運行 core
cd /opt/jumpserver
./jms start -d
多節點部署
多節點部署與上面一致, config.yml 不需要重新生成, 直接複製主節點的配置文件即可
- 登錄到新的節點服務器
yum upgrade -y
yum -y install gcc epel-release git
yum -y install python36 python36-devel
python3.6 -m venv /opt/py3
source /opt/py3/bin/activate
wget https://github.com/jumpserver/jumpserver/releases/download/v2.5.3/jumpserver-v2.5.3.tar.gz
tar xf jumpserver-v2.5.3.tar.gz
mv jumpserver-v2.5.3 jumpserver
yum -y install $(cat /opt/jumpserver/requirements/rpm_requirements.txt)
pip install -r /opt/jumpserver/requirements/requirements.txt
- 複製主節點 config.yml 到 /opt/jumpserver
scp [email protected]:/opt/jumpserver/config.yml /opt/jumpserver
192.168.100.30 爲主 core 服務器 ip,按照提示輸入密碼
- 配置 nfs
yum -y install nfs-utils
showmount -e 192.168.100.99
mount -t nfs 192.168.100.99:/data /opt/jumpserver/data
echo "192.168.100.99:/data /opt/jumpserver/data nfs defaults 0 0" >> /etc/fstab
192.168.100.99 爲 nfs 服務器
- 啓動 core
cd /opt/jumpserver
./jms start -d
- 複製主節點的 jumpserver.conf 到當前節點(如果nginx沒有提前部署,請提前創建目錄)
scp [email protected]:/etc/nginx/conf.d/jumpserver.conf /etc/nginx/conf.d/
192.168.100.30 爲主 core 服務器 ip,按照提示輸入密碼
koko 部署
環境
- 系統: CentOS 7
- IP: 192.168.100.40
+----------+------------+-----------------+---------------+------------------------+
| Protocol | ServerName | IP | Port | Used By |
+==========+============+=================+===============+========================+
| TCP | koko | 192.168.100.40 | 2222, 5000 | Tengine |
+----------+------------+-----------------+---------------+------------------------+
| TCP | koko | 192.168.100.41 | 2222, 5000 | Tengine |
+----------+------------+-----------------+---------------+------------------------+
安裝步驟
安裝 epel 庫
yum upgrade -y
yum -y install epel-release wget
配置防火牆
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.100" port protocol="tcp" port="2222" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.100" port protocol="tcp" port="5000" accept"
firewall-cmd --reload
192.168.100.100 爲 tengine 服務器 ip, 請根據實際情況修改
配置 docker 源
yum install -y yum-utils device-mapper-persistent-data lvm2 wget
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
安裝 docker
yum -y install docker-ce
啓動 docker
systemctl enable docker
systemctl start docker
啓動 koko
docker run --name jms_koko -d \
-p 2222:2222 \
-p 5000:5000 \
-e CORE_HOST=http://192.168.100.100 \
-e BOOTSTRAP_TOKEN=zxffNymGjP79j6BN \
-e LOG_LEVEL=ERROR \
-e REDIS_HOST=192.168.100.20 \
-e REDIS_PORT=6379 \
-e REDIS_PASSWORD=weakPassword \
--privileged=true \
jumpserver/jms_koko:v2.5.3
如果你已經配置好了
域名
和ssl
, 請使用域名註冊
CORE_HOST=https://demo.jumpserver.org
請自行替換此處的域名
BOOTSTRAP_TOKEN
的值從jumpserver/config.yml
裏面獲取
訪問 web頁面會話管理
-終端管理
檢查 koko 註冊
多節點部署
登錄到新的節點服務器, 前面安裝 docker 都是一樣的
yum upgrade -y
yum -y install epel-release wget
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.100" port protocol="tcp" port="2222" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.100" port protocol="tcp" port="5000" accept"
firewall-cmd --reload
yum -y install docker-ce
systemctl enable docker
systemctl start docker
啓動 koko
docker run --name jms_koko -d \
-p 2222:2222 \
-p 5000:5000 \
-e CORE_HOST=http://192.168.100.100 \
-e BOOTSTRAP_TOKEN=zxffNymGjP79j6BN \
-e LOG_LEVEL=ERROR \
-e REDIS_HOST=192.168.100.20 \
-e REDIS_PORT=6379 \
-e REDIS_PASSWORD=weakPassword \
--privileged=true \
jumpserver/jms_koko:v2.5.3
如果你已經配置好了
域名
和ssl
, 請使用域名註冊
CORE_HOST=https://demo.jumpserver.org
請自行替換此處的域名
BOOTSTRAP_TOKEN
的值從jumpserver/config.yml
裏面獲取
訪問 web頁面會話管理
-終端管理
檢查 koko 註冊
guacamole 部署
環境
- 系統: CentOS 7
- IP: 192.168.100.50
+----------+------------+-----------------+---------------+------------------------+
| Protocol | ServerName | IP | Port | Used By |
+==========+============+=================+===============+========================+
| TCP | Guacamole | 192.168.100.50 | 8081 | Tengine |
+----------+------------+-----------------+---------------+------------------------+
| TCP | Guacamole | 192.168.100.51 | 8081 | Tengine |
+----------+------------+-----------------+---------------+------------------------+
安裝步驟
安裝 epel 庫
yum upgrade -y
yum -y install epel-release wget
配置防火牆
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.100" port protocol="tcp" port="8081" accept"
firewall-cmd --reload
192.168.100.100 爲 tengine 服務器 ip, 請根據實際情況修改
配置 docker 源
yum install -y yum-utils device-mapper-persistent-data lvm2 wget
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
安裝 docker
yum -y install docker-ce
啓動 docker
systemctl enable docker
systemctl start docker
啓動 guacamole
docker run --name jms_guacamole -d \
-p 8081:8080 \
-e JUMPSERVER_KEY_DIR=/config/guacamole/key \
-e JUMPSERVER_SERVER=http://192.168.100.100 \
-e BOOTSTRAP_TOKEN=zxffNymGjP79j6BN \
-e GUACAMOLE_LOG_LEVEL=ERROR \
jumpserver/jms_guacamole:v2.5.3
如果你已經配置好了
域名
和ssl
, 請使用域名註冊
JUMPSERVER_SERVER=https://demo.jumpserver.org
請自行替換此處的域名
BOOTSTRAP_TOKEN
的值從jumpserver/config.yml
裏面獲取
訪問 web頁面會話管理
-終端管理
檢查 guacamole 註冊
多節點部署
登錄到新的節點服務器, 前面安裝 docker 都是一樣的
yum upgrade -y
yum -y install epel-release wget
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.100" port protocol="tcp" port="8081" accept"
firewall-cmd --reload
yum -y install docker-ce
systemctl enable docker
systemctl start docker
啓動 guacamole
docker run --name jms_guacamole -d \
-p 8081:8080 \
-e JUMPSERVER_KEY_DIR=/config/guacamole/key \
-e JUMPSERVER_SERVER=http://192.168.100.100 \
-e BOOTSTRAP_TOKEN=zxffNymGjP79j6BN \
-e GUACAMOLE_LOG_LEVEL=ERROR \
jumpserver/jms_guacamole:v2.5.3
如果你已經配置好了
域名
和ssl
, 請使用域名註冊
JUMPSERVER_SERVER=https://demo.jumpserver.org
請自行替換此處的域名
BOOTSTRAP_TOKEN
的值從jumpserver/config.yml
裏面獲取
訪問 web頁面會話管理
-終端管理
檢查 guacamole 註冊
Tengine 代理部署
環境
- 系統: CentOS 7
- IP: 192.168.100.100
+----------+------------+-----------------+---------------+
| Protocol | ServerName | IP | Port |
+==========+============+=================+===============+
| TCP | Tengine | 192.168.100.100 | 80, 443, 2222 |
+----------+------------+-----------------+---------------+
安裝步驟
安裝 epel 庫
yum upgrade -y
yum -y install epel-release wget
配置防火牆
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --zone=public --add-port=2222/tcp --permanent
firewall-cmd --reload
semanage fcontext -a -t httpd_sys_content_t '/opt/jumpserver(/.*)?'
setsebool -P httpd_can_network_connect 1
生產環境下不應該關閉 selinux
安裝 tengine
cd /opt
yum localinstall -y http://demo.jumpserver.org/download/centos/7/tengine-2.3.2-1.el7.ngx.x86_64.rpm
生產環境請自行編譯安裝 tengine
部署 lina
cd /opt
wget https://github.com/jumpserver/lina/releases/download/v2.5.3/lina-v2.5.3.tar.gz
tar -xf lina-v2.5.3.tar.gz
mv lina-v2.5.3 lina
chown -R nginx:nginx lina
部署 luna
cd /opt
wget https://github.com/jumpserver/luna/releases/download/v2.5.3/luna-v2.5.3.tar.gz
tar -xf luna-v2.5.3.tar.gz
mv luna-v2.5.3 luna
chown -R nginx:nginx luna
安裝 nfs
yum -y install nfs-utils
掛載 nfs
showmount -e 192.168.100.99
mkdir -p /opt/jumpserver/data
restorecon -R /opt/jumpserver/data/
mount -t nfs 192.168.100.99:/data /opt/jumpserver/data
echo "192.168.100.99:/data /opt/jumpserver/data nfs defaults 0 0" >> /etc/fstab
192.168.100.99 爲 nfs server 地址,請自行更改
配置 ssh 反向代理
vi /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
stream {
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
access_log /var/log/nginx/tcp-access.log proxy;
open_log_file_cache off;
upstream kokossh { # 四層轉發
server 192.168.100.40:2222;
server 192.168.100.41:2222; # 多節點
# 這裏是 koko ssh 的後端ip
least_conn; # 最少連接算法
}
server {
listen 2222;
proxy_pass kokossh;
proxy_protocol on;
proxy_connect_timeout 1s;
}
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
# tcp_nopush on;
keepalive_timeout 65;
# 關閉版本顯示
server_tokens off;
include /etc/nginx/conf.d/*.conf;
}
配置 http 反向代理
vi /etc/nginx/conf.d/jumpserver.conf
upstream core { # 七層http轉發
server 192.168.100.30:8080;
server 192.168.100.31:8080;
# 這裏是 core 的後端ip
session_sticky; # nginx-sticky-module是nginx的一個模塊,如果沒有安裝需要自行編譯。
}
upstream ws {
server 192.168.100.30:8070;
server 192.168.100.31:8070;
# 這裏是 core 的後端ip
session_sticky;
}
upstream koko {
server 192.168.100.40:5000;
server 192.168.100.41:5000; # 多節點
# 這裏是 koko 的後端ip
session_sticky;
}
upstream guacamole {
server 192.168.100.50:8081;
server 192.168.100.51:8081; # 多節點
# 這裏是 guacamole 的後端ip
session_sticky;
}
server {
listen 80;
# server_name demo.jumpserver.org; # 自行修改成你的域名
# return 301 https://$server_name$request_uri;
# }
# server {
# 推薦使用 https 訪問, 請自行修改下面的選項
# listen 443 ssl;
# server_name demo.jumpserver.org; # 自行修改成你的域名
# ssl_certificate /etc/nginx/sslkey/1_jumpserver.org_bundle.crt; # 自行設置證書
# ssl_certificate_key /etc/nginx/sslkey/2_jumpserver.org.key; # 自行設置證書
# ssl_session_timeout 5m;
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_prefer_server_ciphers on;
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://koko; # koko
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://guacamole/; # guacamole
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://ws;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /api/ {
proxy_pass http://core;
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://core;
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會話保持之nginx-sticky-module模塊
在使用負載均衡的時候會遇到會話保持的問題,常用的方法有:
- ip hash,根據客戶端的IP,將請求分配到不同的服務器上;
- cookie,服務器給客戶端下發一個cookie,具有特定cookie的請求會分配給它的發佈者。
注意:cookie需要瀏覽器支持,且有時候會泄露數據
Sticky工作原理
Sticky是nginx的一個模塊,它是基於cookie的一種nginx的負載均衡解決方案,通過分發和識別cookie,來使同一個客戶端的請求落在同一臺服務器上,默認標識名爲route。
- 客戶端首次發起訪問請求,nginx接收後,發現請求頭沒有cookie,則以輪詢方式將請求分發給後端服務器。
- 後端服務器處理完請求,將響應數據返回給nginx。
- 此時nginx生成帶route的cookie,返回給客戶端。route的值與後端服務器對應,可能是明文,也可能是md5、sha1等Hash值。
- 客戶端接收請求,並保存帶route的cookie。
- 當客戶端下一次發送請求時,會帶上route,nginx根據接收到的cookie中的route值,轉發給對應的後端服務器。
參考1:https://www.cnblogs.com/tssc/p/7481885.html
啓動 nginx
nginx -t
systemctl enable nginx
systemctl start nginx
訪問 http://192.168.100.100 測試是否轉發正常。
默認賬號: admin 密碼: admin
到會話管理-終端管理 檢查 koko Guacamole 等應用的註冊
ssh -p2222 [email protected]
sftp -P2222 [email protected]
密碼: admin
如果是用在 Windows 下, Xshell Terminal 登錄語法如下
ssh [email protected] 2222
sftp [email protected] 2222
密碼: admin
如果能登陸代表部署成功.