docs: 完善部署说明文档,补充 Octane 代理说明及 WebSocket 协议升级避坑指南
This commit is contained in:
+23
-12
@@ -26,16 +26,23 @@ map $http_upgrade $connection_upgrade {
|
||||
# 建议放在 #REWRITE-END 之后,禁止访问敏感文件之前
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
|
||||
# ── Laravel 伪静态规则 ──────────────────────────────────
|
||||
# 如果宝塔的伪静态配置文件 rewrite/chat.ay.lc.conf 为空,
|
||||
# 请在宝塔面板 → 网站 → 伪静态 中选择 "laravel5",
|
||||
# 或者直接在 rewrite/chat.ay.lc.conf 中写入以下内容:
|
||||
#
|
||||
# location / {
|
||||
# try_files $uri $uri/ /index.php?$query_string;
|
||||
# }
|
||||
# ── 1. 静态资源优先由 Nginx 直接响应,动态请求分流给 Octane ──
|
||||
location / {
|
||||
try_files $uri $uri/ @octane;
|
||||
}
|
||||
|
||||
# ── Vite 静态资源缓存(文件名带 hash,可安全长期缓存)────────────
|
||||
# ── 2. API、心跳等动态请求反向代理到本地 8000 端口 (Octane / Roadrunner) ──
|
||||
location @octane {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Scheme $scheme;
|
||||
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;
|
||||
|
||||
proxy_pass http://127.0.0.1:8000;
|
||||
}
|
||||
|
||||
# ── 3. Vite 静态资源缓存(文件名带 hash,可安全长期缓存)────────────
|
||||
location ^~ /build/assets/ {
|
||||
access_log off;
|
||||
expires 1y;
|
||||
@@ -43,7 +50,7 @@ map $http_upgrade $connection_upgrade {
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# ── 常规静态资源缓存(不带 hash,保守缓存 7 天)───────────────
|
||||
# ── 4. 常规静态资源缓存(不带 hash,保守缓存 7 天)───────────────
|
||||
location ~* \.(?:css|js|mjs|png|jpg|jpeg|gif|webp|svg|ico|woff2?|ttf|eot)$ {
|
||||
access_log off;
|
||||
expires 7d;
|
||||
@@ -77,7 +84,11 @@ map $http_upgrade $connection_upgrade {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
|
||||
# 避坑提示:某些宝塔环境全局未配置 $connection_upgrade 变量,
|
||||
# 直接写死 "Upgrade" 能 100% 避免 500 代理握手失败。
|
||||
proxy_set_header Connection "Upgrade";
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@@ -95,7 +106,7 @@ map $http_upgrade $connection_upgrade {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in New Issue
Block a user