Skip to content

Commit

Permalink
Merge pull request #257 from fofapro/0.3.2.11
Browse files Browse the repository at this point in the history
0.3.2.11
  • Loading branch information
xxxxbxxxxx committed Mar 4, 2022
2 parents a4a63ab + 83bf1ff commit f0c8899
Show file tree
Hide file tree
Showing 30 changed files with 334 additions and 233 deletions.
193 changes: 55 additions & 138 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

## 快速安装

### 普通docker镜像安装

拉取 Vulfocus 镜像:

```
docker pull vulfocus/vulfocus:latest
```
Expand All @@ -29,17 +32,48 @@ docker run -d -p 80:80 -v /var/run/docker.sock:/var/run/docker.sock -e VUL_IP=x

![](./imgs/login.png)

## 自定义安装

**以 Centos 7 为例主机已经关闭 `selinux`**

### docker-compose 安装

#### 拉取 vulfocus 和安装项目依赖

```
cd /data
git clone https://github.com/fofapro/vulfocus.git web
```

#### 配置环境参数

```
cd /data/web
vim docker-compose.yaml
```
#### 修改环境运行ip

将环境变量VUL_IP替换成本机ip

![](./imgs/compose.png)



#### 启动项目

```
docker-compose up
```

这时浏览器地址栏输入本机ip即可访问vulfocus服务

## 自定义安装(centos 7系统,需关闭selinux)

环境:

- 语言:python3
- 数据库:sqlite3、redis
- 框架:Django、Celery
- API:djangorestframework
- 系统:Centos 7 , Other
- 系统:Centos 7

### 安装依赖

Expand Down Expand Up @@ -130,7 +164,7 @@ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
yum install mysql-devel
pip3 install PyMysql -i https://pypi.tuna.tsinghua.edu.cn/simple
```
修改/data/web/vulfocus-api/vulfocus/settings.py文件
修改setting文件
```shell script
DATABASES = {
'default': {
Expand Down Expand Up @@ -168,30 +202,13 @@ python manage.py migrate
python manage.py createsuperuser
```

若是执行第一个命令时提示错误ValueError: Dependency on app with no migrations: user
请执行

```shell
python manage.py makemigratations
```

#### 靶场配置:

2. 配置 VUL_IP(`vulfocus/settings.py`),修改为 Docker 服务器的 IP。

3. 修改 CELERY_BROKER_URL(`vulfocus/settings.py`),修改为 Redis 连接地址。

4. 配置 EMAIL_HOST;EMAIL_HOST_USER;EMAIL_HOST_PASSWORD,修改为自己的邮箱配置
#### 启动 Celery(Celery不需要操作后面有自启)
`vulfocus-api` 中启动 Celery:
```
systemctl start redis
celery -A vulfocus worker -l info -E
```
后端启动:
```
celery multi start worker -B -A vulfocus -l info --logfile=celery.log
```

#### 安装uwsgi

Expand All @@ -208,10 +225,9 @@ pip install uwsgi -i https://pypi.tuna.tsinghua.edu.cn/simple
[uwsgi]
uid=nginx
chdir = /data/web/vulfocus-api
module = vulfocus.wsgi
mount = /api=vulfocus.wsgi:application # nginx配置子目录
module = vulfocus.wsgi
mount = /api=vulfocus.wsgi:application
manage-script-name = true
route-run = fixpathinfo:
home = /data/venv_py
socket = /data/tmp/vulfocus_uwsgi.sock
processes = 8
Expand All @@ -223,100 +239,7 @@ enable-threads = true
single-interpreter = true
```

### 安装 Vulfocus Frontend

vulfocus 前端项目,通过 Element-ui + VUE 构建。

环境:
- UI:Element UI
- 框架:vue
- node:v12.16.2
- npm:6.14.4

#### 项目构建

安装依赖(假设本机已经安装node和npm):

```shell script
npm install
```

构建项目:
```
cd /data/web/vulfocus-fronted
npm run build:prod
```

错误处理:

**node sass error**

```
npm install -g yarn
yarn install node-sass
```

**安装core-js报错**

```
npm install core-js@2
```

#### 发行版本

通过 [https://github.com/fofapro/vulfocus/releases](https://github.com/fofapro/vulfocus/releases) 下载最新发布的版本。


### nginx 配置

配置上传文件大小,修改 `nginx.conf` 文件,http 中加入:

```
client_max_body_size 4096M;
```

其中 4096M(4GB) 为上传文件最大限制,可根据实际进行修改,最小配置为 200M 。

#### 带证书多 vhost 的 nginx 配置文件

**位置:**`/etc/nginx/conf.d/vulfocus.xxx.net.conf`

```
server {
listen 80;
server_name vulfocus.xxx.net;
rewrite ^(.*) https://$host$1 permanent;
}
server{
listen 443 ssl http2;
server_name vulfocus.xxx.net;
ssl_certificate /etc/nginx/ssl/1_vulfocus.xxx.net_bundle.crt;
ssl_certificate_key /etc/nginx/ssl/2_vulfocus.xxx.net.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_stapling on;
ssl_stapling_verify on;
client_max_body_size 2048M;
location /{
root /data/vulfocus/vulfocus-frontend/dist;
index index.html;
}
location /api {
uwsgi_pass unix://////data/tmp/vulfocus_uwsgi.sock;
uwsgi_read_timeout 600;
uwsgi_param SCRIPT_NAME /api;
# the uwsgi_params file you installed
include /etc/nginx/uwsgi_params;
}
access_log /data/log/vulfocus.xxx.net.log;
error_log /data/log/vulfocus.xxx.net.log;
}
```

#### 不带证书仅有一个项目配置文件
#### nginx配置

**位置:**`/etc/nginx/nginx.conf`

Expand Down Expand Up @@ -344,6 +267,7 @@ http {
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 4096M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
Expand All @@ -359,7 +283,7 @@ http {
include /etc/nginx/default.d/*.conf;
location /{
root /data/web/vulfocus-frontend/dist;
root /data/web/dist;
index index.html;
}
location /images/ {
Expand Down Expand Up @@ -400,29 +324,13 @@ killasgroup=true
redirect_stderr=true
stdout_logfile=/data/log/vulfoucs_uwsgi.log
```
**位置:**`/etc/supervisord.d/celery.ini`

```
[program:celeryworker]
command=/data/venv_py/bin/celery -A vulfocus worker -l info -E
directory=/data/web/vulfocus-api
user=nginx
numprocs=1
stdout_logfile=/data/log/worker_celery.log
redirect_stderr=true
autostart=true
autorestart=true
startsecs=10
stopasgroup=true
priority=999
```
### 权限以及自启

```
chown -R nginx /data
```

使用 `unix://var/run/docker.sock` **连接 docker 需要配置** 使用 tcp 套接字无需修改
将nginx用户加入docker用户组

```
groupadd docker
Expand All @@ -438,7 +346,7 @@ systemctl enable docker
systemctl enable redis
```

#### 启动
#### 启动服务

```
systemctl start supervisord
Expand All @@ -448,6 +356,16 @@ systemctl start nginx #注意这里一定要确定主机关闭了selinux,
chmod 666 /var/run/docker.sock #注意此处完成配置后尽量不要重新启动docker,否则nginx用户将失去docker的运行权限
```

#### 启动 Celery后台任务

在/data/web/vulfocus-api目录下执行如下命令

```
celery multi start worker -B -A vulfocus -l info --logfile=celery.log
```



#### 防火墙配置

```shell script
Expand Down Expand Up @@ -479,4 +397,3 @@ systemctl restart firewalld.service
chmod 666 /var/run/docker.sock #注意此处完成配置后尽量不要重新启动docker,否则nginx用户将失去docker的运行权限
```


Loading

0 comments on commit f0c8899

Please sign in to comment.