server { listen 80; server_name www.mikivl.online mikivl.online; return 301 https://$host$request_uri; } server { listen 443 ssl http2; server_name www.mikivl.online mikivl.online; ssl_certificate /etc/letsencrypt/live/www.mikivl.online/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/www.mikivl.online/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_session_cache shared:SSL:10m; add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header Referrer-Policy strict-origin-when-cross-origin; # ── 后端 API(反向代理到 Hono,/api/ 优先匹配)── location /api/ { proxy_pass http://hono-server:3001; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # SSE 流式响应必须关闭缓冲 proxy_buffering off; proxy_cache off; proxy_read_timeout 300s; chunked_transfer_encoding on; } # ── 读书笔记 App(/app/ 子路径,SPA)── location /app/ { alias /usr/share/nginx/html/app/; index index.html; try_files $uri $uri/ /app/index.html; } # ── 个人主页(根路径)── location / { root /usr/share/nginx/html/homepage; index index.html; try_files $uri $uri/ /index.html; } # 静态资源长缓存 location ~* \.(js|css|svg|ico|woff2?|png|jpg|webp)$ { expires 1y; add_header Cache-Control "public, immutable"; } }