【Azure Spring Apps】Spring App部署上云遇见 502 Bad Gateway nginx - LuBu0505/My-Code GitHub Wiki

问题描述

在部署Azure Spring App应用后,访问应用,遇见了502 Bad Gateway Nginx。 1.png

问题解答

502 Bad Gateway,  并且由Nginx返回。而自己的应用中,并没有定义Nginx相关内容,所以需要查看问题是否出现在Azure Spring App服务的设置上。

根据Spring App的通信模型图判断,502的请求是由Nginx Ingress抛出( Ingress -> Spring Cloud Gateway) 2.png ( 图片来源:https://learn.microsoft.com/zh-cn/azure/spring-apps/enterprise/how-to-enable-ingress-to-app-tls )

在Spring App中有一个非常重要的配置( ingress-to-app TLS), 它的目的就是确保应用内部的通信也是受TLS保护的。 3.png

如果启用了它,就需要Spring 应用代码中需要使用HTTPS访问。如果没有,Ingress Nginx使用HTTPS的方式访问应用,就会报错 502 Bad Gateway。

找到根源,关闭Ingress-to-app TLS, 502问题消失,问题解决。

参考资料

保护端到端的通信或随时终止 TLS : https://learn.microsoft.com/zh-cn/azure/spring-apps/enterprise/secure-communications-end-to-end#secure-communications-end-to-end-or-terminate-tls-at-any-point

.

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!