没有不值得去解决的问题,也没有不值得去学习的技术!

504 Gateway Time-out nginx/1.17.8 in K8s: NGINX Ingress Controller Times Out After 60 Seconds

Added 3 lines of nginx.ingress related configuration items.

1. Error in K8s: 504 Gateway Time-out nginx/1.17.8. The request timeout limit is 60 seconds. See Figure 1.

Error in K8s: 504 Gateway Time-out nginx/1.17.8. The request timeout limit is 60 seconds.
Figure 1
Plaintext

504 Gateway Time-out
nginx/1.17.8

2. Reference: I had already adjusted the relevant parameters to 300 seconds. However, the error still occurred.

3. Created a new PHP file with an execution time exceeding 120 seconds. Running curl http://127.0.0.1:81/1.php did not produce an error. See Figure 2.

Created a new PHP file with an execution time exceeding 120 seconds. Running curl http://127.0.0.1:81/1.php did not produce an error.
Figure 2
PHP
<?php
sleep(120);
echo 1;
exit;
?>
Plaintext

[root@main-6556cd6b98-jfqc9 public]# curl http://127.0.0.1:81/1.php
1[root@main-6556cd6b98-jfqc9 public]# 

4. However, running curl https://morefun.xxx.xxx.cn/1.php resulted in an error. See Figure 3.

However, running curl https://morefun.xxx.xxx.cn/1.php resulted in an error.
Figure 3
Plaintext
[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. In Rancher, go to Load Balancer to view/edit the YAML. See Figure 4.

In Rancher, go to Load Balancer to view/edit the YAML.
Figure 4

6. Reference URL: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-timeouts . Added 3 lines of nginx.ingress related configuration items. See Figure 5.

Added 3 lines of nginx.ingress related configuration items.
Figure 5
Plaintext

    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. Running curl https://morefun.xxx.xxx.cn/1.php did not produce an error. This matches expectations. The 504 response issue from step 1 has also been resolved. See Figure 6.

Running curl https://morefun.xxx.xxx.cn/1.php did not produce an error. This matches expectations. The 504 response issue from step 1 has also been resolved.
Figure 6
Plaintext

[root@main-dd5b77685-lxg7c public]# curl https://morefun.xxx.xxx.cn/1.php
1[root@main-dd5b77685-lxg7c public]# 

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系