blob: 7033752d4a60875e26e8405847c653c00e8de1f7 [file] [log] [blame]
yyyang3bd72f02025-06-03 16:35:11 +08001server {
2 listen 80;
ybt04391652025-06-07 15:43:46 +08003 server_name team12.10813352.xyz;
4
5 # 前端静态文件配置
ybt27eb6da2025-06-07 20:20:04 +08006 # root /usr/share/nginx/html;
7 # index /dist/index.html;
ybt04391652025-06-07 15:43:46 +08008
9 # 解决 React Router 单页应用路由问题
yyyang3bd72f02025-06-03 16:35:11 +080010 location / {
ybt215afc42025-06-07 18:46:50 +080011 # try_files $uri $uri/ /index.html;
ybt04391652025-06-07 15:43:46 +080012
ybt215afc42025-06-07 18:46:50 +080013 # # 缓存策略
14 # expires 7d; # 静态资源缓存7天
15 # add_header Cache-Control "public";
ybt04391652025-06-07 15:43:46 +080016
ybt215afc42025-06-07 18:46:50 +080017 # # Gzip 压缩
18 # gzip on;
19 # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
20 # gzip_min_length 1024;
21 # gzip_comp_level 6;
22 return 200 "Hello, World!";
yyyang3bd72f02025-06-03 16:35:11 +080023 }
ybt04391652025-06-07 15:43:46 +080024
25 # API 请求代理到后端
yyyang3bd72f02025-06-03 16:35:11 +080026 location /api/ {
ybt04391652025-06-07 15:43:46 +080027 proxy_pass http://202.205.102.121:5001/; # 后端服务地址
yyyang3bd72f02025-06-03 16:35:11 +080028 proxy_set_header Host $host;
29 proxy_set_header X-Real-IP $remote_addr;
30 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
31 proxy_set_header X-Forwarded-Proto $scheme;
ybt04391652025-06-07 15:43:46 +080032
33 # 长连接支持
34 proxy_http_version 1.1;
35 proxy_set_header Connection "";
36
37 # 超时设置
38 proxy_connect_timeout 60s;
39 proxy_send_timeout 60s;
40 proxy_read_timeout 60s;
yyyang3bd72f02025-06-03 16:35:11 +080041 }
ybt04391652025-06-07 15:43:46 +080042
43 # 错误页面配置
44 error_page 404 /index.html;
45 error_page 500 502 503 504 /50x.html;
46
47 # 安全头设置
48 add_header X-Frame-Options "SAMEORIGIN" always;
49 add_header X-XSS-Protection "1; mode=block" always;
50 add_header X-Content-Type-Options "nosniff" always;
51 add_header Referrer-Policy "no-referrer-when-downgrade" always;
52 add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:" always;
53}