【Azure APIM】解决APIM Self-hosted Gateway在AKS上,最开始访问时候遇见的404问题

本文涉及的产品
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
容器服务 Serverless 版 ACK Serverless,952元额度 多规格
简介: 【Azure APIM】解决APIM Self-hosted Gateway在AKS上,最开始访问时候遇见的404问题

问题描述

根据APIM官方文档,创建Self-hosted 网关在AKS中( 使用 YAML 将自承载网关部署到 Kubernetes :https://docs.azure.cn/zh-cn/api-management/how-to-deploy-self-hosted-gateway-kubernetes),但是访问AKS中Services的Endpoint,得到的确实 404页面。

{
    "statusCode": 404,
    "message": "Resource not found"
}

访问截图:

查看AKS POD的日志,也是显示404 错误

PS C:\> kubectl get pods
NAME                                                    READY   STATUS      RESTARTS   AGE
lbapimselftest01-77f5b8db75-7skq4                       1/1     Running     0          5h24m
node-debugger-aks-agentpool-36712949-vmss000000-dlf6h   1/1     Running     0          4h57m
node-debugger-aks-agentpool-36712949-vmss000000-kv2ln   0/1     Completed   0          5h9m
sputnik-metrics-965c64dbc-zt94k                         2/2     Running     0          5h48m
PS C:\> kubectl logs lbapimselftest01-77f5b8db75-7skq4
... ... 
[Info] 2023-10-16T11:26:38.139 [GatewayLogs], isRequestSuccess: False, totalTime: 0, category: GatewayLogs, callerIpAddress: 18.20.91.9, timeGenerated: 2023-10-16T11:26:38.139, region: ChinaNorth3, correlationId: 12909eb4-8dc4-438b-b27d-c667aca4852a, method: GET, url: http://14.6.8.17/echo/resource?param1=sample&param2=test, responseCode: 404, responseSize: 198, cache: none, clientProtocol: HTTP/1.1, lastError: {
"source": "configuration",
"reason": "OperationNotFound",
"message": "Unable to match incoming request to an operation.",
"section": "backend"
}, correlationId: 12909eb4-8dc4-438b-b27d-c667aca4852a
[Info] 2023-10-16T11:26:41.435 [GatewayLogs], isRequestSuccess: False, totalTime: 0, category: GatewayLogs, callerIpAddress: 18.20.91.9, timeGenerated: 2023-10-16T11:26:41.435, region: ChinaNorth3, correlationId: cd4ad591-c3fa-4241-8dca-e10370c8d776, method: GET, url: http://14.6.8.17/, responseCode: 404, responseSize: 198, cache: none, clientProtocol: HTTP/1.1, lastError: {
"source": "configuration",
"reason": "OperationNotFound",
"message": "Unable to match incoming request to an operation.",
"section": "backend"
}, correlationId: cd4ad591-c3fa-4241-8dca-e10370c8d776

 

问题解答

首先,需要查看APIM Self-hosted Gateway是否有关联到被访问的API,测试中所使用的是echo API。

再次访问API接口:http://xxx.xxx.xxx.xxx/echo/resource?param1=sample&param2=test, 依旧是404,就需要查看是否是API的设定中是否允许HTTP访问,

所以,判断这是因为APIs的设置中,只允许了HTTPS访问。当修改为HTTP(S)后,HTTP/HTTPS都可以访问成功。解决了最开始访问出现404的问题。

总结,需要检查APIM中APIs的两个设定:

1)是否为此API添加到 self-hosted gateway

2)访问中配置的是否只能HTTP (HTTPS) 访问

 

参考资料

使用 YAML 将自承载网关部署到 Kubernetes : https://docs.azure.cn/zh-cn/api-management/how-to-deploy-self-hosted-gateway-kubernetes

Azure API Management Self-hosted Gateway - SOAP API not working : https://learn.microsoft.com/en-us/answers/questions/1152222/azure-api-management-self-hosted-gateway-soap-api?page=1

相关实践学习
通过Ingress进行灰度发布
本场景您将运行一个简单的应用,部署一个新的应用用于新的发布,并通过Ingress能力实现灰度发布。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
相关文章
|
24天前
|
Java 应用服务中间件 nginx
【Azure Spring Apps】Spring App部署上云遇见 502 Bad Gateway nginx
【Azure Spring Apps】Spring App部署上云遇见 502 Bad Gateway nginx
|
24天前
|
存储 Kubernetes API
【APIM】Azure API Management Self-Host Gateway是否可以把请求的日志发送到Application Insights呢?让它和使用Azure上托管的 Gateway一样呢?
【APIM】Azure API Management Self-Host Gateway是否可以把请求的日志发送到Application Insights呢?让它和使用Azure上托管的 Gateway一样呢?
|
24天前
|
网络协议
【Azure 应用服务】App Service与Application Gateway组合使用时发生的域名跳转问题如何解决呢?
【Azure 应用服务】App Service与Application Gateway组合使用时发生的域名跳转问题如何解决呢?
|
24天前
|
安全 API
【Azure API 管理】APIM Self-Host Gateway 自建本地环境中的网关数量超过10个且它们的出口IP为同一个时出现的429错误
【Azure API 管理】APIM Self-Host Gateway 自建本地环境中的网关数量超过10个且它们的出口IP为同一个时出现的429错误
|
25天前
|
存储 容器
【Azure 事件中心】为应用程序网关(Application Gateway with WAF) 配置诊断日志,发送到事件中心
【Azure 事件中心】为应用程序网关(Application Gateway with WAF) 配置诊断日志,发送到事件中心
|
3月前
|
Java 应用服务中间件 nginx
【Azure Spring Apps】Spring App部署上云遇见 502 Bad Gateway nginx
在部署Azure Spring App后,用户遇到502 Bad Gateway错误,问题源于Nginx。解决方案是检查并关闭Spring App的ingress-to-app TLS配置,因为若未启用HTTPS访问,Nginx通过HTTPS访问应用会导致此错误。
|
10月前
|
前端开发 应用服务中间件 nginx
用docker和nginx部署前端项目访问本地java网关gateway服务
本地开发 java 微服务项目,但是拿到的对应的web前端项目只有打包编译过后的 dist 目录里的静态资源(里面只有一个index.html和一些编译过后的 js、css文件),前端接口需要先访问到 java 的网关服务,然后网关里再做转发
406 1
|
5天前
|
负载均衡 Java Nacos
SpringCloud基础2——Nacos配置、Feign、Gateway
nacos配置管理、Feign远程调用、Gateway服务网关
SpringCloud基础2——Nacos配置、Feign、Gateway
|
16天前
|
安全 Java 开发者
强大!Spring Cloud Gateway新特性及高级开发技巧
在微服务架构日益盛行的今天,网关作为微服务架构中的关键组件,承担着路由、安全、监控、限流等多重职责。Spring Cloud Gateway作为新一代的微服务网关,凭借其基于Spring Framework 5、Project Reactor和Spring Boot 2.0的强大技术栈,正逐步成为业界的主流选择。本文将深入探讨Spring Cloud Gateway的新特性及高级开发技巧,助力开发者更好地掌握这一强大的网关工具。
71 6
|
2月前
|
负载均衡 Java Spring
Spring cloud gateway 如何在路由时进行负载均衡
Spring cloud gateway 如何在路由时进行负载均衡
284 15