如何在 Traefik 上调大 504 网关超时时间
Traefik 的网关超时默认设置为 60s。如果你的后端服务响应时间超过此值,可能会遇到 504 Gateway Timeout 错误。
要解决此问题,请在命令行选项中添加以下内容(通常在 docker-compose.yml 中):
docker-compose.yml
# 禁用超时
- "--entrypoints.websecure.transport.respondingTimeouts.readTimeout=0"
- "--entrypoints.websecure.transport.respondingTimeouts.writeTimeout=0"
- "--entrypoints.websecure.transport.respondingTimeouts.idleTimeout=0"你可能需要根据配置为多个入口点(例如 web 和 websecure)进行定义。如果每个长时间请求最终都会被重定向到 HTTPS,那么仅为 websecure 设置即可满足需求。
你也可以设置具体的超时值(以秒为单位),而不是用 0 完全禁用。更改后,请重启 Traefik 实例以使新设置生效。
Check out similar posts by category:
Traefik
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow