astro-yukunhh-blog/deploy/nginx-serve.conf
yukun-hh 12dd13a76f feat: init Astro blog with wikilinks, KaTeX and local search
- Astro 5 static blog, zero runtime JS
- Obsidian wikilink remark plugin (slug matches Astro content collection)
- KaTeX math rendering, local search, TOC, archives, tags
- 5 posts on math/physics/ML topics
- deploy scripts for nginx + certbot + rsync
2026-08-14 00:19:33 +08:00

47 lines
1.2 KiB
Text
Raw Permalink 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.

# Yukun's Blog · nginx 共享服务配置片段
# 由 deploy/deploy.sh setup-nginx 上传到 /etc/nginx/snippets/yukun.conf
# 80 与 443 段都 include 此文件,避免重复
root /var/www/yukun;
index index.html;
# gzip 压缩
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_comp_level 6;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/xml+rss
image/svg+xml;
# 静态资源长缓存Astro 构建产物带 hash可放心强缓存
location ~* \.(?:css|js|woff2?|ttf|otf|svg|png|jpg|jpeg|gif|webp|ico|avif)$ {
expires 30d;
add_header Cache-Control "public, immutable";
access_log off;
}
# sitemap 不缓存
location = /sitemap-index.xml { add_header Cache-Control "no-cache"; }
location ~ ^/sitemap.* { add_header Cache-Control "no-cache"; }
# Astro 目录式 URL确保 index.html 能解析
location / {
try_files $uri $uri/ $uri.html =404;
}
# 自定义 404
error_page 404 /404.html;
# 安全头
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;