feat: add support for customizing port and installation path

This commit is contained in:
zclaiqcc
2023-04-17 11:06:13 +08:00
parent ef4b60b1b0
commit 4130d95294
3 changed files with 34 additions and 16 deletions

16
FAQ.md
View File

@@ -36,6 +36,14 @@ Upgrade your docker engine and retry.
Port conflicts. Based on the port number in the error message, troubleshoot which service is occupying it and handle the conflict manually.
### How to customize safeline-ce installation path?
With the latest `compose.yaml`, you can manually modify the `SAFELINE_DIR` variable in the `.env` file after `setup.sh`.
### How to change the default port of SafeLine management, as for `:9443` is already in used by some other services?
With the latest `compose.yaml`, you can add `MGT_PORT` variable in `.env` file.
## Login
### TOTP login failed with correct code
@@ -88,6 +96,14 @@ As shown, you shall start docker first. Try `systemctl start docker` or manually
可能是您的 docker 版本过低,升级 docker 到最新版本尝试一下。
### 如何自定义 SafeLine 安装路径?
基于最新的 `compose.yaml`,你可以手动修改 `.env` 文件的 `SAFELINE_DIR` 变量。
### 如何修改 SafeLine 后台管理的默认端口?本机 `:9443` 已经被别的服务占用了
基于最新的 `compose.yaml`,你可以手动添加 `MGT_PORT` 变量到 `.env` 文件。
## 登录问题
### OTP 认证码登录失败

View File

@@ -16,7 +16,7 @@ services:
restart: always
image: postgres:15.2
volumes:
- ${PWD}/resources/postgres/data:/var/lib/postgresql/data
- ${SAFELINE_DIR}/resources/postgres/data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=safeline-ce
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?postgres password required}
@@ -31,12 +31,12 @@ services:
restart: always
image: chaitin/safeline-mgt-api:${IMAGE_TAG:?image tag required}
volumes:
- ${PWD}/resources/management:/resources/management
- ${PWD}/resources/nginx:/resources/nginx
- ${PWD}/logs:/logs
- ${SAFELINE_DIR}/resources/management:/resources/management
- ${SAFELINE_DIR}/resources/nginx:/resources/nginx
- ${SAFELINE_DIR}/logs:/logs
- /etc/localtime:/etc/localtime:ro
ports:
- 9443:1443
- ${MGT_PORT:-9443}:1443
environment:
- MANAGEMENT_RESOURCES_DIR=/resources/management
- NGINX_RESOURCES_DIR=/resources/nginx
@@ -52,8 +52,8 @@ services:
restart: always
image: chaitin/safeline-detector:${IMAGE_TAG}
volumes:
- ${PWD}/resources/detector:/resources/detector
- ${PWD}/logs/detector:/logs/detector
- ${SAFELINE_DIR}/resources/detector:/resources/detector
- ${SAFELINE_DIR}/logs/detector:/logs/detector
environment:
- LOG_DIR=/logs/detector
networks:
@@ -66,8 +66,8 @@ services:
restart: always
image: chaitin/safeline-mario:${IMAGE_TAG}
volumes:
- ${PWD}/resources/mario:/resources/mario
- ${PWD}/logs/mario:/logs/mario
- ${SAFELINE_DIR}/resources/mario:/resources/mario
- ${SAFELINE_DIR}/logs/mario:/logs/mario
environment:
- LOG_DIR=/logs/mario
- GOGC=100
@@ -82,12 +82,12 @@ services:
restart: always
image: chaitin/safeline-tengine:${IMAGE_TAG}
volumes:
- ${PWD}/resources/nginx:/etc/nginx
- ${PWD}/resources/management:/resources/management
- ${PWD}/resources/detector:/resources/detector
- ${PWD}/logs/nginx:/var/log/nginx
- ${SAFELINE_DIR}/resources/nginx:/etc/nginx
- ${SAFELINE_DIR}/resources/management:/resources/management
- ${SAFELINE_DIR}/resources/detector:/resources/detector
- ${SAFELINE_DIR}/logs/nginx:/var/log/nginx
- /etc/localtime:/etc/localtime:ro
- ${PWD}/resources/cache:/usr/local/nginx/cache
- ${SAFELINE_DIR}/resources/cache:/usr/local/nginx/cache
- /etc/resolv.conf:/etc/resolv.conf
ulimits:
nofile: 131072

View File

@@ -23,7 +23,7 @@ fi
command -v docker > /dev/null || abort "docker not found, unable to deploy"
compose_plugin=true
compose_command="docker compose"
docker --help | grep compose | grep v2 > /dev/null || echo "aaa" compose_plugin=false || compose_command="docker-compose"
docker --help | grep compose | grep v2 > /dev/null || compose_plugin=false || compose_command="docker-compose"
if [[ "x${compose_plugin}" = "xfalse" ]]; then
command -v docker-compose > /dev/null && docker-compose --version | grep v2 > /dev/null || abort "docker compose v2 not found, unable to deploy"
@@ -36,10 +36,12 @@ fi
ENV_FILE=".env"
if [[ ! -f ${ENV_FILE} ]]; then
echo "SAFELINE_DIR=$(pwd)" >> .env
echo "IMAGE_TAG=latest" >> .env
echo "MGT_PORT=9443" >> .env
echo "POSTGRES_PASSWORD=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
fi
echo "Setup success!"
echo "Run '$compose_command up -d' to start WAF."
echo "Run '$compose_command up -d' to start SafeLine."
echo "And then visit https://<SafeLine-IP>:9443."