初始化1

This commit is contained in:
zg
2026-07-16 13:03:11 +08:00
parent 0bdfcbc1c8
commit e6b0f287cc
100 changed files with 12184 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
#!/bin/bash
# 允许大文件上传(最大 2GB
# 全局 http 块 + server 块同时设置
# 1. nginx.conf http 块加全局默认值
if ! grep -q 'client_max_body_size' /etc/nginx/nginx.conf; then
sed -i '/gzip_types text\/plain/i\ client_max_body_size 2048m;\n client_body_timeout 300s;' /etc/nginx/nginx.conf
echo "[OK] nginx.conf: client_max_body_size 2048m"
else
echo "[SKIP] nginx.conf already has client_max_body_size"
fi
# 2. 每个 server 块也加上(覆盖可能的全局设置)
for f in /etc/nginx/conf.d/*.conf; do
if ! grep -q 'client_max_body_size' "$f"; then
sed -i '/server_name/a\ client_max_body_size 2048m;' "$f"
echo "[OK] $(basename $f): added"
else
echo "[SKIP] $(basename $f): already has"
fi
done
# 3. 更新 Python API 模板(未来新增规则自动带此配置)
TEMPLATE="/opt/nginx-api/services/nginx_service.py"
if [ -f "$TEMPLATE" ] && ! grep -q 'client_max_body_size' "$TEMPLATE"; then
sed -i '/server_name {domain};/a\ client_max_body_size 2048m;' "$TEMPLATE"
systemctl restart nginx-api
echo "[OK] Python template updated + API restarted"
else
echo "[SKIP] Python template already has client_max_body_size"
fi
# 4. 验证
echo ""
echo "=== nginx -t ==="
nginx -t && systemctl reload nginx && echo "=== DONE ==="