1、在 K8s 中报错:504 Gateway Time-out nginx/1.17.8。请求超时限制为 60 秒。如图1
504 Gateway Time-out nginx/1.17.8
2、参考网址:https://www.shuijingwanwq.com/2020/02/19/3936/ 。已经将相关参数调整为 300 秒。但是仍然报错。
3、新建一个 PHP 文件,运行时间超过 120 秒。curl http://127.0.0.1:81/1.php 未报错。如图2
<?php sleep(120); echo 1; exit; ?>
[root@main-6556cd6b98-jfqc9 public]# curl http://127.0.0.1:81/1.php 1[root@main-6556cd6b98-jfqc9 public]#
4、但是 curl https://morefun.xxx.xxx.cn/1.php 报错。如图3
[root@main-6556cd6b98-jfqc9 /]# curl https://morefun.xxx.xxx.cn/1.php <html> <head><title>504 Gateway Time-out</title></head> <body> <center><h1>504 Gateway Time-out</h1></center> <hr><center>nginx/1.17.8</center> </body> </html> [root@main-6556cd6b98-jfqc9 /]#
5、在 Rancher 中 负载均衡 查看/编辑 YAML。如图4
6、参考网址:https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-timeouts 。添加 3 行 nginx.ingress 相关配置项。如图5
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300" nginx.ingress.kubernetes.io/proxy-read-timeout: "300" nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
7、curl https://morefun.xxx.xxx.cn/1.php 未报错。符合预期。步骤1响应504的问题也得到解决。如图6
[root@main-dd5b77685-lxg7c public]# curl https://morefun.xxx.xxx.cn/1.php 1[root@main-dd5b77685-lxg7c public]#
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/251073.html