fix(docker): 前端 HEALTHCHECK 改用 127.0.0.1,nginx 仅监听 IPv4 导致 localhost(::1) 连接被拒

This commit is contained in:
Sisyphus committed 2026-08-19 20:06:37 +08:00
1 parent 40dd101797
commit d88755d0d6
1 file changed
+3 -2
+3 -2
View File
@@ -41,8 +41,9 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf
# 复制构建产物(dist/ 含 index.html + assets/)到 nginx 根目录
COPY --from=build /app/dist /usr/share/nginx/html
# 健康检查
# 健康检查——nginx 仅监听 IPv4 (0.0.0.0:80),必须用 127.0.0.1 而非 localhost
# (localhost 会解析到 ::1 IPv6,导致 wget 连接被拒)
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
CMD wget -qO- http://localhost:80/healthz || exit 1
CMD wget -qO- http://127.0.0.1:80/healthz || exit 1
EXPOSE 80