46 lines
1.4 KiB
Nginx Configuration File
46 lines
1.4 KiB
Nginx Configuration File
server {
|
||||
|
|
listen 8081;
|
|||
|
|
server_name localhost;
|
|||
|
|
|
|||
|
|
gzip on;
|
|||
|
|
gzip_vary on;
|
|||
|
|
gzip_min_length 1024;
|
|||
|
|
gzip_comp_level 6;
|
|||
|
|
gzip_proxied any;
|
|||
|
|
gzip_types text/plain text/css text/javascript application/javascript application/json
|
|||
|
|
application/xml application/rss+xml image/svg+xml font/ttf font/otf;
|
|||
|
|
|
|||
|
|
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 "strict-origin-when-cross-origin" always;
|
|||
|
|
|
|||
|
|
error_log /var/log/nginx/error.log warn;
|
|||
|
|
access_log /var/log/nginx/access.log;
|
|||
|
|
|
|||
|
|
# 独立容器时根路径重定向到文档前缀;经网关反代 /docs/ 时通常不会命中。
|
|||
|
|
location = / {
|
|||
|
|
return 302 /docs/;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# VitePress base=/docs/:磁盘上是 dist/assets/...,URL 为 /docs/assets/...
|
|||
|
|
location /docs {
|
|||
|
|
alias /usr/share/nginx/html/;
|
|||
|
|
index index.html;
|
|||
|
|
try_files $uri $uri/ $uri.html /docs/index.html;
|
|||
|
|
add_header Cache-Control "no-cache, must-revalidate" always;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
location ^~ /docs/assets/ {
|
|||
|
|
alias /usr/share/nginx/html/assets/;
|
|||
|
|
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
error_page 404 /docs/404.html;
|
|||
|
|
|
|||
|
|
error_page 500 502 503 504 /50x.html;
|
|||
|
|
location = /50x.html {
|
|||
|
|
root /usr/share/nginx/html;
|
|||
|
|
}
|
|||
|
|
}
|