Skip to content
On this page

拉取代码


shell
git clone https://github.com/w5teams/w5.git

安装依赖库


shell
# 默认国外源,国外服务器使用
pip3 install -r requirements.txt

# 使用国内源,国内服务器使用
pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# 如果遇到以下错误,请升级 pip
# ERROR: Could not build wheels for cryptography, bcrypt which use PEP 517 and cannot be installed directly
pip3 install -U pip

修改配置文件


执行 vi config.iniredis 没有密码无需填写

ini
[mysql]
host = 127.0.0.1
port = 3306
database = w5_db
user = root
password = root

[redis]
host = 127.0.0.1
port = 6379
database = 0
password =

运行项目


shell
[root@VM-8-9-centos w5]# python3 run.py 
 ##@&$||;..!||||||||||;;||||||||%$@##@
 #@$%||||!`    .;|||||;. `:!||||||$@@@
 @$%||||||||!`               `!||||$@&
 &$||||||||||!.              :|||||%$$
 $%||||||||||`              `!||||||$$
 $%|||||||||;.                :|||||$$
 $%||||||||!.                  .;|||$$
 &$||||||||;      .!|:.          `!%$$
 @$%||||||||;. .:|||!'            .!&&
 #@$|||||||||||||||!`             '%@@
 ##@$%|||||||||||!`              :%@#@
 ###@&$||||||||!`               !&###@
 #####@&&%||||:.             `%&#####@
 ########&&&%:   W5 SOAR  '$&@#######@  v0.1
=============================================
* Web : https://w5.io
* Github : https://github.com/w5hub/w5
=============================================
[2020-12-07 12:07:45 +0800] [4072781] [INFO] Starting gunicorn 20.0.4
[2020-12-07 12:07:45 +0800] [4072781] [INFO] Listening at: http://0.0.0.0:8888 (4072781)
[2020-12-07 12:07:45 +0800] [4072781] [INFO] Using worker: flask_sockets.Worker
[2020-12-07 12:07:45 +0800] [4072798] [INFO] Booting worker with pid: 4072798
[2020-12-07 12:07:45 +0800] [4072800] [INFO] Booting worker with pid: 4072800
[2020-12-07 12:07:45 +0800] [4072802] [INFO] Booting worker with pid: 4072802

访问 W5 SOAR


  • 访问地址: ip:8888, (访问不了请检查服务器防火墙)
  • 账号密码: 账号:admin,密码:12345678 (登录后请及时修改密码)

login

生产环境部署


1. 使用 Supervisor 守护进程

shell
# 生成 supervisor 配置文件
echo_supervisord_conf3 > /etc/supervisord.conf

2. 修改配置 vi /etc/supervisord.conf 最下面加入

ini
[program:w5]
# 脚本执行命令
command = python3 run.py
# 项目目录路径,必须是绝对路径
directory = /root/w5
autostart = true
autorestart = true
redirect_stderr = true
# 项目日志路径
stdout_logfile=/opt/w5.log 
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20

3. 开启守护进程

shell
# 启动
supervisord3 -c /etc/supervisord.conf

# 如遇到以下错误:
# Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.

# 因为已经启动,所以直接更新配置即可
supervisorctl3 -c /etc/supervisord.conf update

4. 管理命令:

shell
# 启动项目
supervisorctl3 start w5

# 停止项目
supervisorctl3 stop w5

# 重启项目
supervisorctl3 restart w5

Nginx 绑定域名 不配置域名访问,无需看此项


1. 配置 Nginx

shell
server {
    listen 80;
    server_name demo.w5.io;

    location / {
        proxy_pass http://localhost:8888/;
        proxy_set_header Host $http_host;
        proxy_set_header X-real-ip $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    # Websockt 设置项
    location /echo {
        proxy_pass http://localhost:8888/echo;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    access_log off;
}

2. 重启 Nginx


nginx -s reload

访问 W5 SOAR

浏览器访问:http://demo.w5.io