Files
user-system/scripts/ops/fix_nginx.sh
long-agent 5b6bd93179 refactor: 整理项目根目录结构
整理内容:
- 删除 60+ 临时测试输出文件 (*.txt)
- 移动二进制文件到 bin/ 目录
- 移动 Shell 脚本到 scripts/ 目录
  - scripts/dev/: check_gitea.sh, check_sub2api.sh, run_tests.sh
  - scripts/deploy/: deploy_*.sh, simple_deploy.sh
  - scripts/ops/: fix_nginx.sh, fix_ssl.sh, install_docker.sh
  - scripts/test/: test_*.sh, test_*.bat
- 移动批处理文件到 scripts/
- 移动 Python 脚本到 tools/
- 清理临时日志文件

保留根目录必要文件:
- go.mod, go.sum, go.work
- Makefile, docker-compose.yml
- .env.example, .gitignore
- README.md, AGENTS.md, DEPLOY_GUIDE.md

验证: go build ./... && go test ./... 通过
2026-04-07 18:10:36 +08:00

61 lines
1.9 KiB
Bash

#!/bin/bash
# 修复 Nginx 配置
echo "配置 Nginx..."
cat > /etc/nginx/sites-available/tksea << 'EOF'
# HTTP 重定向
server {
listen 80;
server_name tksea.top www.tksea.top api.tksea.top gitea.tksea.top sub.tksea.top;
location /.well-known/acme-challenge/ { root /var/www/html; }
location / { return 301 https://$host$request_uri; }
}
# HTTPS - 主域名和 Gitea
server {
listen 443 ssl http2;
server_name tksea.top www.tksea.top gitea.tksea.top;
ssl_certificate /etc/letsencrypt/live/tksea.top/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/tksea.top/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_protocols TLSv1.2 TLSv1.3;
add_header Strict-Transport-Security "max-age=63072000" always;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
# HTTPS - API 和 Sub
server {
listen 443 ssl http2;
server_name api.tksea.top sub.tksea.top;
ssl_certificate /etc/letsencrypt/live/tksea.top/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/tksea.top/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_protocols TLSv1.2 TLSv1.3;
add_header Strict-Transport-Security "max-age=63072000" always;
underscores_in_headers on;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
EOF
nginx -t && systemctl reload nginx
echo "完成! 检查: sudo systemctl status nginx"