Skip to content
所有標籤

#nginx

5 篇文章
tech guide

nginx 502:跨 Compose 專案的容器 DNS 解析踩坑

跨 Compose 專案時 service name 不可解析,要加 network alias 才能讓 nginx 找到容器。

tech guide

nginx 重啟後 Cloudflare 一直回 502,但 origin 明明是正常的

nginx 重啟期間短暫出錯,Cloudflare 偵測到 origin 不健康後停止轉發請求,自己回傳 502。localhost 打 origin 是 200,nginx access log 空白是關鍵線索。等 Cloudflare 自動 re-check 即可恢復。

tech guide

用 nginx conf.d 管理多服務 reverse proxy:以島島為例

單一 nginx.conf 隨服務增加變得難以維護,用 include conf.d/*.conf 按服務拆分是標準解法。

tech guide

nginx 第一個請求必定 502,之後全部正常

nginx 用 set $variable 做動態 upstream 時,DNS 快取每 30 秒過期,第一個請求因無可用 IP 而 502。升到 nginx 1.27.3 改用 upstream + resolve 參數,DNS 在背景非同步更新,根治問題。

tech guide

Cloudflare Free Plan 設維護頁:Custom Error Pages 不能用,改用 Worker

Cloudflare Custom Error Pages 需要付費方案,Free Plan 可改用 Worker inline HTML 攔截 5xx。