diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5afc815..cbeb6dec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## [0.35.23] + +### Performance + +- 优化消息时间格式 +- 优化app功能 + ## [0.35.20] ### Features diff --git a/README.md b/README.md index 08ff09c94..ec94ff607 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ git clone -b pro --depth=1 https://gitee.com/aipaw/dootask.git # 2、Enter directory cd dootask -# 3、Installation(Custom port installation: ./cmd install --port 2222) +# 3、Installation(Custom port installation, as: ./cmd install --port 80) ./cmd install ``` @@ -43,7 +43,8 @@ cd dootask ### Change port ```bash -./cmd port 2222 +# This method only replaces the HTTP port. To replace the HTTPS port, please read the SSL configuration below +./cmd port 80 ``` ### Change App Url @@ -91,7 +92,16 @@ cd dootask ./cmd mysql "your command" # To run a mysql command (backup: Backup database, recovery: Restore database) ``` -### NGINX PROXY SSL +### SSL configuration + +#### Method 1: Automatic configuration + +```bash +# Running commands in a project +./cmd https +``` + +#### Method 2: Nginx Agent Configuration ```bash # 1、Nginx config add @@ -99,8 +109,8 @@ proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; -# 2、Running commands in a project -./cmd https +# 2、Running commands in a project (If you unconfigure the NGINX agent, run: ./cmd https close) +./cmd https agent ``` ## Upgrade diff --git a/README_CN.md b/README_CN.md index 96f391ca7..fe5fda5e6 100644 --- a/README_CN.md +++ b/README_CN.md @@ -29,7 +29,7 @@ git clone -b pro --depth=1 https://gitee.com/aipaw/dootask.git # 2、进入目录 cd dootask -# 3、一键安装项目(自定义端口安装 ./cmd install --port 2222) +# 3、一键安装项目(自定义端口安装,如:./cmd install --port 80) ./cmd install ``` @@ -43,7 +43,8 @@ cd dootask ### 更换端口 ```bash -./cmd port 2222 +# 此方法仅更换http端口,更换https端口请阅读下面SSL配置 +./cmd port 80 ``` ### 更换URL @@ -92,7 +93,16 @@ cd dootask ./cmd mysql "your command" # 运行 mysql 命令 (backup: 备份数据库,recovery: 还原数据库) ``` -### NGINX 代理 SSL +### SSL 配置 + +#### 方式一:自动配置 + +```bash +# 在项目下运行命令,根据提示执行即可 +./cmd https +``` + +#### 方式二:Nginx 代理配置 ```bash # 1、Nginx 代理配置添加 @@ -100,8 +110,8 @@ proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; -# 2、在项目下运行命令 -./cmd https +# 2、在项目下运行命令(如果取消 Nginx 代理配置请运行:./cmd https close) +./cmd https agent ``` ## 升级更新 diff --git a/bin/https b/bin/https new file mode 100644 index 000000000..cc89dd9af --- /dev/null +++ b/bin/https @@ -0,0 +1,169 @@ +#!/bin/sh + +#fonts color +Green="\033[32m" +Yellow="\033[33m" +Red="\033[31m" +GreenBG="\033[42;37m" +YellowBG="\033[43;37m" +RedBG="\033[41;37m" +Font="\033[0m" + +#notification information +OK="${Green}[OK]${Font}" +Warn="${Yellow}[警告]${Font}" +Error="${Red}[错误]${Font}" + +cd "$( + cd "$(dirname "$0")" || exit + pwd +)" || exit + +#================================================================ +#================================================================ + +success() { + echo -e "${OK} ${GreenBG}$1${Font}" +} + +warning() { + echo -e "${Warn} ${YellowBG}$1${Font}" +} + +error() { + echo -e "${Error} ${RedBG}$1${Font}" +} + +info() { + echo -e "$1" +} + +env_get() { + local key=$1 + local value=`cat $(dirname "$PWD")/.env | grep "^$key=" | awk -F '=' '{print $2}'` + echo "$value" +} + +env_set() { + local key=$1 + local val=$2 + local exist=`cat $(dirname "$PWD")/.env | grep "^$key="` + if [ -z "$exist" ]; then + echo "$key=$val" >> $(dirname "$PWD")/.env + else + sed -i "/^${key}=/c\\${key}=${val}" $(dirname "$PWD")/.env + fi +} + +#================================================================ +#================================================================ + +check() { + while [ -z "$domain" ]; do + read -rp "请输入你的域名: " domain + # 判断域名是否合法 + if [ -z "$domain" ]; then + error "域名不能为空" + elif [ -z "$(echo "$domain" | grep -E '^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$')" ]; then + error "域名格式不正确" + domain="" + fi + done + + success "正在域名DNS解析IP..." + local domain_ip=$(ping -c 1 "${domain}" 2>/dev/null | grep PING | cut -d "(" -f2 | cut -d ")" -f1) + local local_ip=$(curl -sk ip.sb) + info "域名DNS解析IP: ${domain_ip}" + info "本机IP: ${local_ip}" + + sleep 2 + if [[ "$(echo "${local_ip}" | tr '.' '+' | bc)" == "$(echo "${domain_ip}" | tr '.' '+' | bc)" ]]; then + success "域名DNS解析IP 与 本机IP 匹配" + sleep 2 + else + warning "域名DNS解析IP 与 本机IP 不匹配,是否继续操作? [Y/n]" + read -r continue_next + [[ -z ${continue_next} ]] && continue_next="Y" + case $continue_next in + [yY][eE][sS] | [yY]) + success "继续操作" + sleep 2 + ;; + *) + error "操作终止" + exit 2 + ;; + esac + fi +} + +install() { + local sitePath="$(dirname "$PWD")/docker/nginx/site" + local sslPath="$sitePath/ssl" + if [[ -f "$sslPath/$domain.key" && -f "$sslPath/$domain.crt" ]]; then + warning "$domain 证书文件已存在,是否删除并继续操作? [Y/n]" + read -r continue_install + [[ -z ${continue_install} ]] && continue_install="Y" + case $continue_install in + [yY][eE][sS] | [yY]) + rm -f "$sslPath/$domain.key" + rm -f "$sslPath/$domain.crt" + success "继续操作" + sleep 2 + ;; + *) + error "操作终止" + exit 2 + ;; + esac + fi + + apk add --no-cache openssl socat + curl https://get.acme.sh | sh + if [[ 0 -ne $? ]]; then + error "安装证书生成脚本失败" + exit 1 + fi + + if /root/.acme.sh/acme.sh --issue -d "${domain}" -w "$(dirname "$PWD")/public" --standalone -k ec-256 --force --test; then + success "SSL 证书测试签发成功,开始正式签发" + rm -rf "/root/.acme.sh/${domain}_ecc" + sleep 2 + else + error "SSL 证书测试签发失败" + rm -rf "root/.acme.sh/${domain}_ecc" + exit 1 + fi + + if /root/.acme.sh/acme.sh --issue -d "${domain}" -w "$(dirname "$PWD")/public" --server letsencrypt --standalone -k ec-256 --force; then + success "SSL 证书生成成功" + sleep 2 + mkdir -p $sslPath + if /root/.acme.sh/acme.sh --installcert -d "${domain}" --fullchainpath "${sslPath}/${domain}.crt" --keypath "${sslPath}/${domain}.key" --ecc --force; then + success "SSL 证书配置成功" + sleep 2 + fi + else + error "SSL 证书生成失败" + rm -rf "/root/.acme.sh/${domain}_ecc" + exit 1 + fi + + env_set "APP_URL" "https://${domain}" + + cat >${sitePath}/ssl.conf <