chore: harden build and deployment workflow

This commit is contained in:
237899745
2026-07-27 13:07:14 +08:00
parent 6692736e88
commit f5377e51bb
10 changed files with 408 additions and 71 deletions

View File

@@ -9,7 +9,9 @@ server {
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), geolocation=(), microphone=()" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; font-src 'self' data:; media-src 'self' blob: https:; connect-src 'self' https: ws: wss:; worker-src 'self' blob:; object-src 'none'; base-uri 'self'; frame-ancestors 'self'; form-action 'self';" always;
# 隐藏Nginx版本
server_tokens off;
@@ -32,6 +34,21 @@ server {
try_files $uri $uri/ =404;
}
location /assets/ {
root /usr/share/nginx/html;
expires 1y;
}
location /libs/ {
root /usr/share/nginx/html;
expires 30d;
}
location /downloads/ {
alias /runtime/downloads/;
expires 1h;
}
# 后端API反向代理
location /api/ {
proxy_pass http://backend:40001;
@@ -43,6 +60,7 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 修复使用当前请求协议http或https适用于直接IP访问
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Request-ID $request_id;
proxy_cache_bypass $http_upgrade;
# Cookie传递配置验证码session需要
@@ -69,5 +87,6 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 修复使用当前请求协议http或https适用于直接IP访问
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Request-ID $request_id;
}
}