在 K8s 中报错:504 Gateway Time-out nginx/1.17.8,NGINX 入口控制器在 60 秒后请求超时
1、在 K8s 中报错:504 Gateway Time-out nginx/1.17.8。请求超时限制为 60 秒。如图12、参考网址:https://www.shuijingwanwq.com/2020/02/19/3936/ 。已经将相关参数调整为 300 秒。但是仍然报错。
3、新建一个 PHP 文件,运行时间超过 120 秒。curl http://127.0.0.1:81/1.php 未报错。如图24、但是 curl https://morefun.xxx.xxx.cn/1.php 报错。如图35、在 Rancher 中 负载均衡 查看/编辑 YAML。如图46、参考网址:https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-timeouts 。添加 3 行 nginx.ingress 相关配置项。如图57、curl https://morefun.xxx.xxx.cn/1.php 未报错。符合预期。步骤1响应504的问题也得到解决。如图6
504 Gateway Time-out
nginx/1.17.8
<pre class="wp-block-syntaxhighlighter-code">
<?php
sleep(120);
echo 1;
exit;
?>
</pre>
[root@main-6556cd6b98-jfqc9 public]# curl http://127.0.0.1:81/1.php
1[root@main-6556cd6b98-jfqc9 public]#
<pre class="wp-block-syntaxhighlighter-code">
[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 /]#
</pre>
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
[root@main-dd5b77685-lxg7c public]# curl https://morefun.xxx.xxx.cn/1.php
1[root@main-dd5b77685-lxg7c public]#





