赞
踩
部署过程相对复杂!请耐心浏览!
目录
3.1 删除mairadb(CentOS7自带mariadb)
6.4 获取SECRET_KEY、BOOTSTRAP_TOKEN秘钥
10.1 下载guacamole-server及ssh-forward
14.4 pip3 install virtualenv 报错
为了避免非云运维的人员对公司内部的服务器进行错误操作,导致损失,那么我们就需要用到跳板机,即使公司内部人员,需要操作服务器也得经过验证。并且连接上跳板机后,所有的登陆和操作记录都会被记录。
跳板机:
跳板机就是一台服务器而已,运维人员在使用管理服务器的时候,必须先连上跳板机,然后才能去操控内网中的服务器,才能登录到目标设备上进行维护和操作。跳板机他是属于内网堡垒机的范畴,是一种用于单点登陆的主机应用系统。跳板机缺点,仅仅实现服务器登陆的安全,但是没有实现对于运维开发人员行为操控和审计。使用跳板机可能会对服务器进行错误操作,很难定位到操作人。
堡垒机:
结合了跳板机的优点,并且可以记录操作人员和记录,堡垒机能够创建系统账号,该系统账号功能是属于角色区分的作用,但是也无法确认该账号的执行人。
堡垒机的作用:
由于跳板机的不足,企业需要更新,更好,更安全的技术理念去管理服务器的运维操作,需要一种能够满足角色管理,角色授权,信息资源访问控制,操作记录和审计,系统更变和维护控制等等需求。
1、核心系统运维和安全审计管理
2、过滤和拦截非打请求访问,恶意攻击,拒绝不合法命令,进行审计口监控,报警和责任追踪
3、报警,记录,分析,处理
1、单点登陆功能
2、账号管理功能
3、身份认证
4、资源授权
5、访问控制
- 虚拟机平台:VMware
- IP:192.168.132.65 (自定义)
- 虚拟机配置:1vpcu 1核 2G 40G (测试学习环境,生产环境具体情况而定)
- 没有特别说明情况下,所有wget或下载的文件默认存储在/opt目录下
- python = 3.6.x Python版本必须3.6及以上
- mysql5.7 版本必须大于5.6
- redis 缓存型数据库
- systemctl stop firewalld
- systemctl disable firewalld
-
- 关闭selinux,重启后生效
- 修改/etc/selinux/config 文件
- 将SELINUX=enforcing改为SELINUX=disabled
- date
-
- yum install ntpdate -y
- timedatectl set-timezone Asia/Shanghai
- ntpdate ntp1.aliyun.com
- systemctl enable ntpdate
-
- date #查看系统时间是否同步准确
hostnamectl set-hostname jumpserver
- mkdir /etc/yum.repos.d/bak
- mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/ #备份yum源
-
- wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
-
- yum clean all
- yum makecache #清楚缓存,重写建立yum仓库
yum install -y bash-completion vim lrzsz wget expect net-tools nc nmap tree dos2unix htop iftop iotop unzip telnet sl psmisc nethogs glances bc ntpdate openldap-devel gcc zlib zlib-devel
echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf #永久修改,无需重启
ls --help可查看,显示部分中文表示修成功
reboot
先安装mysql,否则后续mysql的安装报错很难处理,先保证mysql安装完成。
centos7自带的类mysql数据库是mariadb,会跟mysql冲突,必须先删除!!!
- cd /opt
-
- wget http://dev.mysql.com/get/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
- tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
-
- mkdir mysql
- mv mysql-community*.rpm mysql #移动到mysql目录下
-
- rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
- rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
- rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
- rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
-
- rpm -ivh mysql-community-devel-5.7.26-1.el7.x86_64.rpm (平时安装mysql这个可以省略,但部署jumpserver后续步骤会用到mysql-devel工具)
-
- systemctl start mysqld
- systemctl enable mysqld
如果报以下错误,请加上--nodeps 属性,添加该属性表示不检查依赖关系。
warning: mysql-community-server-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
查看root用户初始密码
grep 'temporary password' /var/log/mysqld.log
如果查看密码为空白,需要删除mysql残留文件
- rm -rf /var/lib/mysql
- systemctl restart mysqld
- grep 'temporary password' /var/log/mysqld.log
- mysql -uroot -p
- #黏贴刚刚拿到的密码
-
- show variables like 'validate_password%'; #查看密码复杂度
-
- mysql> set global validate_password_length=6; #长度
- mysql> set global validate_password_mixed_case_count=0; #字符个数
- mysql> set global validate_password_special_char_count=0; #特殊符号个数
- mysql> flush privileges;
-
- create database jumpserver default charset 'utf8' collate 'utf8_bin'; #新建名为jumpserver的数据库
- set password for 'root'@'localhost' =password('yz123456'); #更改mysql的root用户密码为yz123456
- create user 'jumpserver'@'%' IDENTIFIED BY 'yz123456'; #创建mysql用户jumpserver且密码为yz123456
-
- grant all privileges on root.* to 'jumpserver'@'%' identified by 'yz123456';
- grant all privileges on jumpserver.* to 'jumpserver'@'%' identified by 'yz123456'; #赋权
密码复杂度属性解释:
validate_password_length #密码长度
validate_password_mixed_case_count #大小写字符个数
validate_password_number_count #数字个数
validate_password_special_char_count #特殊字符个数
pyhton版本必须大于或等于3.6.X
- cd /opt
- wget https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tgz
- tar -xvf Python-3.6.10.tgz
-
- yum install -y openssl openssl-devel #ssl工具,必须在安装python前安装
-
- cd /opt/Python-3.6.10/
- ./confiure --prefix=/usr/local/python3.6 #编译并指定python3.6目录
- make -j3 && make instal #编译安装
-
- echo "PATH="/usr/local/python3.6/bin:$PATH"" >> /etc/profile #添加环境
- source /etc/profile #刷新一下环境
- ##随后命令行输入python3.6就能进入了(quit()退出)
注意终端输入python、python3.6结果不同,python2.7为Linux自带,不需要卸载,不影响。
- mkdir /root/.pip
- touch /root/.pip/pip.conf
- vim /root/.pip/pip.conf
-
- #########将下面的内容写入###########
-
- [global]
- index-url = https://mirrors.aliyun.com/pypi/simple/
创建虚拟环境是为了应对一台服务区中的多个应用所需的相同版本py,不同模块的场景。virtualenv为python虚拟化模块工具。
- pip3 install virtualenv
-
- cd /usr/local
- virtualenv --python=python3 jmp_venvl
注意此时有两个python解释器
解释器本体就是:/usr/local/python3.6/bin/python3.6
虚拟解释器就是:/usr/local/jmp_venel/bin/python3
切换python虚拟环境
- source /usr/local/jmp_venvl/bin/activate #刷新环境,可以进去python虚拟环境,进入后终端会哟jmp_venvl标识
-
- deactivate #退出当前的虚拟环境/切换回物理真实环境
此时输入python也是3.6版本而不是2.7,因为此时在虚拟环境中。
- yum -y install redis
- systemct start redis
- systemct enable redis
-
- redis-cli #验证
- [root@jumpserver ~]# redis-cli
- 127.0.0.1:6379> ping
- PONG #返回PONG证明可以正常启动
- wget https://github.com/jumpserver/jumpserver/releases/download/v2.1.0/jumpserver-v2.1.0.tar.gz
- tar -zxvf jumpserver-v2.1.0.tar.gz
- ln -s /opt/jumpserver-v2.1.0 jumpserver
yum install -y bash-completion vim lrzsz wget expect net-tools nc nmap tree dos2unix htop iftop iotop unzip telnet sl psmisc nethogs glances bc ntpdate openldap-devel
注意:安装jumperserver模块,必须保证在py3的虚拟环境,一定要先激活环境再安装!!!
- cd /opt/jumpserver/requirements/
- cat /opt/jumpserver/requirements/requirements.txt
-
- source /usr/local/jmp_venvl/bin/activate #非常重要!!!
- pip3 install -r /opt/jumpserver/requirements/requirements.txt
-
- deactivate
pip3 requirements.txt 报错
No matching distribution found for mysqlclient==1.3.14
提示找不到mysqlclient==1.3.14,在requirements.txt中确实有这一项,需要安装mysql-devel ,如果按照我步骤安装mysql不会出现这个报错。网上很多帖子使用yum安装, yum install mysql-devel 提示没有yum源, 因为采用手动安装mysql,所以没有mysql的repo源,我们手动安装mysql-devel即可,若报错,加上 --nodeps 属性。
- ###解决方法###
- cd /opt/mysql
- rpm -ivh mysql-community-devel
后续步骤需要用到这两个秘钥
- #获取SECRET_KEY
- if [ "$SECRET_KEY" = "" ]; then SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50` ; echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc; echo $SECRET_KEY; else echo $SECRET_KEY; fi
-
- #获取BOOTSTRAP_TOKEN
- if [ "$BOOTSTRAP_TOKEN" = "" ]; then BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`; echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc; echo $BOOTSTRAP_TOKEN; else echo $BOOTSTRAP_TOKEN; fi
SECRET_KEY: UtsbR8W5fJ81M4s6k0vcITUiASsHOTRKOIq0KvCnzzXupQpqcp BOOTSTRAP_TOKEN: 1iTfoBKVFv13PtSg
- cd /opt/jumpserver
- cp config_example.yml config.yml #example是配置文件模板,真正生效的配置文件是config.yml
- vim config.yml
-
- #将刚刚两个密钥填入,并填一下数据库密码"yz123456"
-
egrep -v "^#|^$" config.yml 可以把注释内容以及空行去掉再显示,可以简洁查看配置文件有效信息。此处两个密钥要更改成你的,在填写数据库密码,其他不用更改。
- [root@jumpserver jumpserver]# cd /opt/jumpserver
- [root@jumpserver jumpserver]# egrep -v "^#|^$" config.yml
- SECRET_KEY: UtsbR8W5fJ81M4s6k0vcITUiASsHOTRKOIq0KvCnzzXupQpqcp #KEY
- BOOTSTRAP_TOKEN: 1iTfoBKVFv13PtSg #TOKEN
- DB_ENGINE: mysql #使用的数据库是什么
- DB_HOST: 127.0.0.1 #默认的IP地址
- DB_PORT: 3306 #默认端口
- DB_USER: jumpserver #默认的用户就是我们在数据库那步创建的user
- DB_PASSWORD:yz123456 #数据库的密码
- DB_NAME: jumpserver #数据库用户名
- HTTP_BIND_HOST: 0.0.0.0 #jumpserver运行的地址,写的0表示绑定这台机器对内对外所有的IP,如果是在公网的jumpserver会很危险
- HTTP_LISTEN_PORT: 8080 #jumpserver后台启动的地址
- WS_LISTEN_PORT: 8070 #WEB SOCKET
- REDIS_HOST: 127.0.0.1 # 默认redis的IP
- REDIS_PORT: 6379 #默认redis的端口
jumpserver这个程序由python的web框架django开发而来。必须先进行数据迁移,生成库表的信息,才能运行程序。
- [root@jumpserver jumpserver]# mysql -u root -p
- Enter password:
-
- mysql> show databases; #查看数据库
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | jumpserver |
- | mysql |
- | performance_schema |
- | test |
- +--------------------+
- 5 rows in set (0.01 sec)
- mysql> use jumpserver #进入到jumpserver这库中
- Database changed
- mysql> show tables; #查看库中的表
- Empty set (0.00 sec) #还未导入,库中无表
一定要先进入python虚拟环境!!!
- source /usr/local/jmp_venvl/bin/activate
- cd /opt/jumpserver/apps
- python3 /opt/jumpserver/apps/manage.py makemigrations #显示浅蓝色字体表示成功
- python3 /opt/jumpserver/apps/manage.py migrate #显示多张表导入成功并有OK字样
-
- deactivate
报错使用请添加--fake属性,python manage.py migrate --fake
如果数据表返回OK位置显示faked表示迁移失败,请检查mysql启动情况,systemctl status mysqld,确保mysqld已经running。
数据迁移成功
- (jmp_venvl) [root@jumpserver /]# mysql -u root -p
- Enter password:
-
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | jumpserver |
- | mysql |
- | performance_schema |
- | sys |
- +--------------------+
- 5 rows in set (0.12 sec)
-
- mysql> use jumpserver;
- Database changed
-
- mysql> show tables;
- +----------------------------------------------+
- | Tables_in_jumpserver |
- +----------------------------------------------+
- | applications_databaseapp |
- | applications_remoteapp |
- | assets_adminuser |
- | assets_asset |
- | assets_asset_labels |
- ...
- cd /opt/jumpserver
- /opt/jumpserver/jms start -d #-d表示后台运行 start|stop|restart|status
验证jumpserver初始化页面
192.168.136.65:8080
koko组件实现了SSH Server 和 Web Terminal Server的组件,提高SSH和WebSocket接口,使用Paramiko和Flask开发,可以让我们在线去像xshell一样在网页上去敲命令。他是golang编程语言开发的。和之前的coco组件(py写的)相比,性能更高。
- cd /opt
- wget https://github.com/jumpserver/koko/releases/download/v2.1.0/koko-v2.1.0-linux-amd64.tar.gz
- tar -zxvf koko-v2.1.0-linux-amd64.tar.gz
- cd koko-v2.1.0-linux-amd64/
- cp config_example.yml config.yml
- vim config.yml
-
- ##填入获取的BOOTSTRAP_TOKEN,将redis的注释删掉###
-
- [root@jumpserver koko-v2.1.0-linux-amd64]# egrep -v "^#|^$" config.yml
- CORE_HOST: http://127.0.0.1:8080
- BOOTSTRAP_TOKEN: 1iTfoBKVFv13PtSg
- REDIS_HOST: 127.0.0.1
- REDIS_PORT: 6379
- REDIS_PASSWORD:
- REDIS_CLUSTERS:
- REDIS_DB_ROOM:
-
- ./koko -d #启动koko服务
Apache 跳板机项目,Jumpserver使用其他组件实现RDP功能,Jumpserver并没有修改其他代码而是添加了额外的插件,支持Jumpserver调用。(这里的RDP就是远程桌面协议,通过浏览器就能操作后台服务器)
官网下载链接:Apache Guacamole™: 1.2.0
- cd /opt
- wget -O docker-guacamole-v2.1.1.tar.gz https://github.com/jumpserver/docker-guacamole/archive/master.tar.gz
- tar -xf docker-guacamole-v2.1.1.tar.gz
-
- #解压后目录名为docker-guacamole-master,目录下有三个文件#
- [root@jumpserver opt]# ls /opt/docker-guacamole-master/
- Dockerfile guacamole.properties etc
-
- cd /opt/docker-guacamole-master/
- wget http://download.jumpserver.org/public/guacamole-server-1.2.0.tar.gz #下载guacamole-server
- tar -zxvf guacamole-server-1.2.0.tar.gz
-
- wget http://download.jumpserver.org/public/ssh-forward.tar.gz--2020-08-09 14:33:54-- http://download.jumpserver.org/public/ssh-forward.tar.gz #下载ssh-forward
- tar -zxvf ssh-forward.tar.gz
-
- cd /opt/docker-guacamole-master/guacamole-server-1.2.0 #进入源码包
-
- yum -y install cairo-devel libjpeg-turbo-devel libjpeg-devel libpng-devel libtool uuid-devel freerdp-devel pango-devel libssh2-devel libtelnet-devel libvncserver-devel libwebsockets-devel pulseaydio-libs-devel openssl-devel libvorbis-devel libwebp-devel #安装依赖
ffmpeg工具是用来处理媒体文件
- yum -y install epel-release
-
- rpm -v --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
- rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
-
- yum -y install ffmpeg ffmpeg-devell
- cd /opt/docker-guacamole-master/guacamole-server-1.2.0 #进入源码包
- ./configure --with-init-dir=/etc/init.d #编译
- make && make install #编译安装
- yum -y install java-1.8.0-openjdk
-
- cd /opt
- wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.74/bin/apache-tomcat-9.0.74.tar.gz
- tar -xf apache-tomcat-9.0.74.tar.gz
- mv apache-tomcat-9.0.74 tomcat9
- rm -rf /opt/tomcat9/webapps/*
-
- cd /opt/docker-guacamole-master/
- wget http://download.jumpserver.org/release/v2.1.1/guacamole-client-v2.1.1.tar.gz #guacamole-clent里有一个war包和jar包
- tar -xf guacamole-client-v2.1.1.tar.gz
-
- ##更改tomcat配置文件###
- sed -i 's/Connector port="8080"/Connector port="8081"/g' /opt/tomcat9/conf/server.xml
- echo "java.util.logging.ConsoleHandler.encoding = UTF-8" >> /opt/tomcat9/conf/logging.properties
- ###3个软链接###
- ln -sf /opt/docker-guacamole-master/guacamole-client-v2.1.1/guacamole-1.0.0.war /opt/tomcat9/webapps/ROOT.war
- ln -sf /opt/docker-guacamole-master/guacamole-client-v2.1.1/guacamole-auth-jumpserver-1.0.0.jar /config/guacamole/extensions/guacamole-auth-jumpserver-1.0.0.jar
- ln -sf /opt/docker-guacamole-master/guacamole.properties /config/guacamole/guacamole.properties
./bashrc是一个类似与profile的环境变量配置文件。在/root目录下使用 ls --all可以查看,默认情况下隐藏。
- export JUMPSERVER_SERVER=http://127.0.0.1:8080
- echo "export JUMPSERVER_SERVER=http://127.0.0.1:8080" >> ~/.bashrc
- export BOOTSTRAP_TOKEN=Ovn181zT7q7a8Die
- echo "export B00TSTRAP_TOKEN=Ovn181zT7q7a8Die" >> ~/.bashrc
- export JUMPSERVER_KEY_DIR=/config/guacamole/keys
- echo "export JUMPSERVER_KEY_DIR=/config/guacamole/keys" >> ~/.bashrc
- export GUACAMOLE_HOME=/config/guacamole
- echo "export GUACAMOLE_HOME=/config/guacamole" >> ~/.bashrc
- export GUACAMOLE_LOG_LEVEL=ERROR
- echo "export GUACAMOLE_LOG_LEVEL=ERROR" >> ~/.bashrc
- export JUMPSERVER_ENABLE_DRIVE=true
- echo "export JUMPSERVER_ENABLE_DRIVE=true" >> ~/.bashrc
参数含义:
JUMPSERVER_SERVER 指core访问的地址
BOOTSTARAP_TOKEN一定要改为自己的,如果忘记就去jumpserver下的config.yml里去找
JUMPSERVER_KEY_DIR 认证成功后key存放目录
GUACAMOLE_HOME 为guacamole.properties配置文件所在目录
GUACAMOLE_LOG_LEVEL 为生成日志等级
JUMPSERVER_ENABLE_DRIVE 为rdp协议挂载共享盘
- /etc/init.d/guacd start #启动服务
- /opt/tomcat9/bin/startup.sh #启动tomcat
lina是属于前端模块,负责页面的展现,luna现在是web terminal 前端、计划前端页面都有该项目提供。jumpserver只提供api,不再负责后台渲染html,他和lina结合可以实现网页上命令行界面的终端。
useradd -M -s /sbin/nologin nginx
- cd /opt
- wget https://github.com/jumpserver/lina/releases/download/v2.1.0/lina-v2.1.0.tar.gz
- wget https://github.com/jumpserver/luna/releases/download/v2.1.1/luna-v2.1.1.tar.gz
- tar -zxvf lina-v2.1.0.tar.gz
- tar -zxvf luna-v2.1.1.tar.gz
- mv lina-v2.1.0 lina
- mv luna-v2.1.1 luna
- chown -R nginx:nginx lina #改变他的属主属组,让他归nginx管理
- chown -R nginx:nginx luna #改变他的属主属组,让他归nginx管理
- cd /opt
- wget http://nginx.org/download/nginx-1.22.0.tar.gz
- tar -zxvf nginx-1.22.0.tar.gz
- wget https://gitcode.net/mirrors/vozlt/nginx-module-vts/-/archive/master/nginx-module-vts-master.zip #可能会报错,但链接是没问题的,需要去windows主机下载然后传到/opt目录下
- unzip nginx-module-vts-master.zip
-
- yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel make
-
- cd /opt/nginx-1.22.0/
- ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --add-module=/opt/nginx-module-vts-master/
- make && make install
-
- nginx -V #查看nginx安装信息
- nginx -t #测试ngixn,返回nginx状态,带有successful为成功
vim /usr/local/nginx/conf/nginx.conf
直接复制即可,无需更改,黏贴格式出错请使用vim黏贴模式,:set paste。
- #user nobody;
- worker_processes 1;
-
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
-
- #pid logs/nginx.pid;
-
-
- events {
- worker_connections 1024;
- }
-
-
- http {
- include mime.types;
- default_type application/octet-stream;
- vhost_traffic_status_zone; #流量状态监控
- #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 logs/access.log main;
- log_format main '{ "@timestamp": "$time_local", '
- '"@fields": { '
- '"uri":"$request_uri",'
- '"url":"$uri",'
- '"upstream_addr":"$upstream_addr",'
- '"remote_addr": "$remote_addr", '
- '"remote_user": "$remote_user", '
- '"body_bytes_sent": "$body_bytes_sent", '
- '"host":"$host",'
- '"server_addr":"$server_addr",'
- '"request_time": "$request_time", '
- '"request_time":"$request_time",'
- '"status":"$status",'
- '"request": "$request", '
- '"request_method": "$request_method", '
- '"size":$body_bytes_sent,'
- '"upstream_time":"$upstream_response_time"'
- '"http_referrer": "$http_referer", '
- '"body_bytes_sent":"$body_bytes_sent", '
- '"http_x_forwarded_for": "$http_x_forwarded_for", '
- '"http_user_agent": "$http_user_agent" } }';
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- #gzip on;
-
- server {
- listen 80;
- server_name localhost;
-
- #charset koi8-r;
-
- #access_log logs/host.access.log main;
-
- location / {
- root html;
- index index.html index.htm;
- }
- location /status {
- vhost_traffic_status_display;
- vhost_traffic_status_display_format html;
- }
- #error_page 404 /404.html;
-
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
-
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
-
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
-
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
-
-
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # listen 8000;
- # listen somename:8080;
- # server_name somename alias another.alias;
-
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
-
-
- # HTTPS server
- #
- #server {
- # listen 443 ssl;
- # server_name localhost;
-
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
-
- # ssl_session_cache shared:SSL:1m;
- # ssl_session_timeout 5m;
-
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
-
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
-
- }
- ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
- cd /usr/local/sbin/
- ./nginx #开启服务
192.168.136.65
192.168.136.65/status
监控列表各项信息
Server main 主服务器
**Host:**主机名
**Version:**版本号
**Uptime:**服务器运行时间
Connections active:当前客户端的连接数 reading:读取客户端连接的总数 writing:写入客户端连接的总数
Requsts accepted:接收客户端的连接总数 handled:已处理客户端的连接总数 Total:请求总数 Req/s:每秒请求的数量
Shared memory:共享内存 name:配置中指定的共享内存名称 maxSize:配置中指定的共享内存的最大限制 usedSize:共享内存的当前大小 usedNode:共享内存中当前使用的节点数
Server zones 服务器区域
zone:当前区域
Requests Total:请求总数 Req/s:每秒请求数 time:时间
Responses:状态码数量 1xx、2xx、3xx、4xx、5xx:表示响应不同状态码数量 Total:响应状态码的总数
Traffic表示流量 Sent:发送的流量 Rcvd:接收的流量 Sent/s:每秒发送的流量 Rcvd/s:每秒接收的流量
Cache表示缓存 Miss:未命中的缓存数 Bypass:避开的缓存数 Expirde:过期的缓存数 Stale:生效的缓存数 Updating:缓存更新的次数 Revalidated:重新验证的缓存书 Hit:缓存命中数 Scarce:未达缓存要求的请求次数Total:总数
vim /usr/local/nginx/conf/nginx.conf
实际上之只更改了server部分,为了大家方便复制,我把整个文件拷贝下来。黏贴格式出错请使用vim黏贴模式,:set paste。
- worker_processes 1;
-
- events {
- worker_connections 1024;
- }
-
-
- http {
- include mime.types;
- default_type application/octet-stream;
- vhost_traffic_status_zone; #流量状态监控
- #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 logs/access.log main;
- log_format main '{ "@timestamp": "$time_local", '
- '"@fields": { '
- '"uri":"$request_uri",'
- '"url":"$uri",'
- '"upstream_addr":"$upstream_addr",'
- '"remote_addr": "$remote_addr", '
- '"remote_user": "$remote_user", '
- '"body_bytes_sent": "$body_bytes_sent", '
- '"host":"$host",'
- '"server_addr":"$server_addr",'
- '"request_time": "$request_time", '
- '"request_time":"$request_time",'
- '"status":"$status",'
- '"request": "$request", '
- '"request_method": "$request_method", '
- '"size":$body_bytes_sent,'
- '"upstream_time":"$upstream_response_time"'
- '"http_referrer": "$http_referer", '
- '"body_bytes_sent":"$body_bytes_sent", '
- '"http_x_forwarded_for": "$http_x_forwarded_for", '
- '"http_user_agent": "$http_user_agent" } }';
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- #gzip on;
- server {
- listen 80;
- client_max_body_size 100m; #录像和文件上传大小限制
- #charset koi8-r;
-
- #access_log logs/host.access.log main;
-
- location /ui/ {
- try_files $uri / /index.html;
- alias /opt/lina/;
- }
- location /status {
- vhost_traffic_status_display;
- vhost_traffic_status_display_format html;
- }
- 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/ { #当我们请求koko,他会通过proxy_pass进行反向代理
- 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
- cd /usr/local/sbin/nginx
- ./nginx
如果重启nginx后出现以下报错
nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:1
检查格式,通常就是少了一个括号或者多一个括号。
192.168.136.65
此时不再是8080端口,而是80端口,因为被nginx代理,默认用户名密码均为admin。
[root@jumpserver wheels]# cd /opt/py3/lib/python3.6/site-packages
'pidfile' has no attribute 'TimeoutPIDLockFile' pidfile模块没有TimeoutPIDLockFile属性,我安装另一个教程会出现此报错,无法解决,重新开了一台虚拟机,按照我的本文教程不会出现该问题。
nginx: [emerg] still could not bind()报错表示80端口被占用
查看端口占用情况
netstat -anp | grep 80
使用kill -9 杀死进程也没用,nginx:worker 或者nginx:master一直自动重启占用80端口
- ###解决方法###
- cd /usr/local/sbin/nginx
- pkill nginx
- ./nginx
python3 /opt/jumpserver/apps/manage.py makemigrations 报错
python3 /opt/jumpserver/apps/manage.py migrate
mysql数据库密码纯数字错误
- ###解决方法###
- 改密码解决方法,提前避免改为问题,密码需要有英文字母和数字组合。
- 如果你前面mysql密码设置的跟我一样不会出现该问题。
-
- (jum_venel) [root@jumpserver apps]# mysqladmin -ujumpserver -p password
- Enter password:
- New password:
- Confirm new password:
缺少openssl工具,需要卸载python3重新编译
- ###解决方法###
- rm -rf /usr/local/python3.6/ #卸载原先的python3.6
- yum install openssl openssl-devel -y
- cd /etc/python
- ./configure --prefix=/usr/local/python3.6
- make -j3 && make install
由于没有设置jms、nginx开机自启动,所以没吃开机需要手动启动
- ###解决方法###
- source /usr/local/jmp_venvl/bin/activate
- /opt/jumpserver/jms start -d
- ./usr/local/sbin/nginx
手动部署jumpserver堡垒机(完整过程+常见错误)_IT.cat的博客-CSDN博客
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。