From 60a1efb78e8316b6db18927835193ddd64e6e308 Mon Sep 17 00:00:00 2001 From: shenlan Date: Wed, 23 Jul 2025 17:06:54 +0800 Subject: [PATCH 1/2] Convert proxy setup to GitHub Action --- .github/workflows/setup-proxy-cn-homepage.yml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/setup-proxy-cn-homepage.yml diff --git a/.github/workflows/setup-proxy-cn-homepage.yml b/.github/workflows/setup-proxy-cn-homepage.yml new file mode 100644 index 0000000..34b0411 --- /dev/null +++ b/.github/workflows/setup-proxy-cn-homepage.yml @@ -0,0 +1,63 @@ +name: Setup Proxy for cn-homepage.svc.plus + +on: + workflow_dispatch: + inputs: + dummy: + description: 'Manual trigger' + required: false + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: 🚀 Configure Nginx on proxy host + uses: appleboy/ssh-action@v1.0.0 + with: + host: ${{ secrets.PROXY_HOST }} + username: ${{ secrets.PROXY_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + script: | + apt-get update + apt-get install -y nginx + cat <<'NGINXCONF' > /etc/nginx/sites-available/default + # 1. HTTP 自动跳转到 HTTPS + server { + listen 80; + server_name cn-homepage.svc.plus; + return 301 https://cn-homepage.svc.plus$request_uri; + } + + # 2. HTTPS 静态站部署 svc.plus + server { + listen 443 ssl http2; + server_name cn-homepage.svc.plus; + + ssl_certificate /etc/ssl/svc.plus.pem; + ssl_certificate_key /etc/ssl/svc.plus.rsa.key; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!aNULL:!MD5; + + # 3. 指向静态构建输出目录 + root /var/www/XControl/ui/homepage/out; + index index.html; + + # 4. 页面访问(含 SPA fallback) + location / { + try_files $uri $uri/ /index.html; + } + + # 5. 静态资源缓存优化 + location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?)$ { + expires 30d; + access_log off; + add_header Cache-Control "public"; + } + + # 6. 隐藏 . 文件(如 .DS_Store) + location ~ /\. { + deny all; + } + } + NGINXCONF + systemctl restart nginx From b109f3116e4c03737228fe5f0ff8dcc98b432809 Mon Sep 17 00:00:00 2001 From: shenlan Date: Wed, 23 Jul 2025 17:09:58 +0800 Subject: [PATCH 2/2] Update setup-proxy-cn-homepage.yml --- .github/workflows/setup-proxy-cn-homepage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/setup-proxy-cn-homepage.yml b/.github/workflows/setup-proxy-cn-homepage.yml index 34b0411..cd498f3 100644 --- a/.github/workflows/setup-proxy-cn-homepage.yml +++ b/.github/workflows/setup-proxy-cn-homepage.yml @@ -14,8 +14,8 @@ jobs: - name: 🚀 Configure Nginx on proxy host uses: appleboy/ssh-action@v1.0.0 with: - host: ${{ secrets.PROXY_HOST }} - username: ${{ secrets.PROXY_USER }} + host: ${{ secrets.CN_PROXY_HOST }} + username: ${{ secrets.CN_PROXY_HOST_USER }} key: ${{ secrets.SSH_PRIVATE_KEY }} script: | apt-get update