# PhoneRail 需求文档站(VitePress 静态产物) # 部署到 /etc/nginx/conf.d/phonerail-docs.conf # # ⚠️ 只 listen 127.0.0.1 —— 正门是统一门户 http://phonerail.home.example:7755/, # 门户的 vhost 反代到 127.0.0.1:7757,不需要这个端口对外可达。 # 这台机器实测是大范围/DMZ 转发,绑 0.0.0.0 = 公网直连即绕过登录 # (现有 12 个应用就是这个状态,见 skill §关键约定 7)。这里不重蹈。 # 代价:内网直连 10.5.5.13:7757 也进不来。要留内网兜底就再加一行 # `listen 10.5.5.13:7757;` —— 但那样公网同样可达,是个真实的取舍。 server { listen 127.0.0.1:7757; server_name _; root /root/phonerail-docs; index index.html; charset utf-8; # nginx.conf 里只有 gzip on 没有 gzip_types,默认只压 text/html, # 不在这里补上的话 JS/CSS 全是裸传(见 skill §关键约定 6) gzip_static on; gzip_types text/plain text/css application/javascript application/json application/xml image/svg+xml font/woff font/woff2; gzip_min_length 1024; gzip_vary on; # VitePress 的 assets 文件名带内容哈希,可以永久缓存 location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # 入口页绝不能被缓存:缓存住之后页面不再走服务器, # 门户的 auth_request 就永远不会触发(skill §关键约定 8 踩过两次的坑) location = /index.html { add_header Cache-Control "no-cache"; } # cleanUrls: /foo -> foo.html;只有一篇正文时也保持这个行为。 # 结尾必须是 =404 而不是 /404.html —— try_files 的最后一个参数是内部跳转, # 会把 404 页以 HTTP 200 吐出去(实测过)。交给下面的 error_page 才有真 404。 location / { try_files $uri $uri.html $uri/ =404; } error_page 404 /404.html; server_tokens off; access_log /var/log/nginx/phonerail-docs.access.log; error_log /var/log/nginx/phonerail-docs.error.log warn; }