34 lines
785 B
Nginx Configuration File
34 lines
785 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# 容器内健康检查、日志都走 stdout
|
|
access_log /dev/stdout;
|
|
error_log /dev/stderr warn;
|
|
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 1024;
|
|
gzip_types text/plain text/css application/javascript application/json image/svg+xml;
|
|
|
|
# 带 hash 的构建产物可以长缓存
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# 入口 HTML 不缓存,保证发版后立刻生效
|
|
location = /index.html {
|
|
add_header Cache-Control "no-cache, must-revalidate";
|
|
}
|
|
|
|
# SPA 路由回退
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|