front/nginx-k3s.conf
xiaolipro 5ae57745be
Some checks failed
Build and Deploy Front / deploy (push) Failing after 3m46s
1
2026-11-11 15:59:38 +08:00

69 lines
1.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# k3s 方案 A:仅静态 SPA。API 由浏览器按域名直连;TLS 由 Traefik 终结。
server {
listen 80;
server_name _;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml image/svg+xml;
root /usr/share/nginx/html;
index index.html;
# 官网静态(若存在);否则回退 SPA
location = / {
try_files /site/index.html /index.html =404;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
location = /site {
return 301 /;
}
location = /site/ {
return 301 /;
}
location = /site/index.html {
return 301 /;
}
location ^~ /site/ {
try_files $uri =404;
expires 7d;
add_header Cache-Control "public";
access_log off;
}
location = /favicon.ico {
try_files /favicon.png /favicon.ico =404;
expires 7d;
add_header Cache-Control "public";
access_log off;
}
location = /index.html {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# 微信域名校验文件
location ~* ^/MP_verify_[A-Za-z0-9]+\.txt$ {
try_files $uri =404;
add_header Cache-Control "no-cache";
}
location ~* \.(?:js|css|woff2?|ttf|eot|svg|png|jpe?g|gif|webp|ico|map)$ {
try_files $uri =404;
expires 7d;
add_header Cache-Control "public";
access_log off;
}
# SPA 路由回退
location / {
try_files $uri $uri/ /index.html;
}
}