Pre Merge pull request !762 from AprilWind/dev-nginx

This commit is contained in:
AprilWind 2025-09-12 08:45:04 +00:00 committed by Gitee
commit e834293cb2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -14,8 +14,11 @@ http {
keepalive_timeout 65; keepalive_timeout 65;
# 限制body大小 # 限制body大小
client_max_body_size 100m; client_max_body_size 100m;
client_body_buffer_size 128k;
# 开启静态资源压缩 # 开启静态资源压缩
gzip_static on; gzip_static on;
# 隐藏版本号
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" ' '$status $body_bytes_sent "$http_referer" '
@ -69,7 +72,24 @@ http {
return 403; return 403;
} }
# hash 文件长缓存
location ~* \.[a-f0-9]{8}\.(css|js)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# 图片/字体缓存
location ~* \.(jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf)$ {
expires 30d;
add_header Cache-Control "public";
}
location / { location / {
# HTML 页面不缓存
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
root /usr/share/nginx/html; # docker映射路径 不允许更改 root /usr/share/nginx/html; # docker映射路径 不允许更改
try_files $uri $uri/ /index.html; try_files $uri $uri/ /index.html;
index index.html index.htm; index index.html index.htm;