我使用AWS API GateWay和HTTPIntegration将请求映射到外部 API,在映射的请求标头中注入外部 API 密钥。我知道我可以根据请求或字符串提供“映射自”参数来提供 API 密钥,但我也可以从 AWS Secrets Manager 映射标头值吗?在下面的控制台示例中,我使用了原始字符串。

我使用 Microsoft C# .NET YARP作为 ASP.NET Core Web API(最新版本)以及 Swagger 和 Kestrel 前面的 API 网关。YARP 用于到许多微服务的内部重定向。
问题:
例如:https://URL/swagger/index.html => 执行 POST FUNCTION => YARP_API_GATEWAY => SERVICE_API_PORT
前任。配置:
"ReverseProxy": {
"Routes": [
{
"RouteId": "Service1",
"ClusterId": "ServiceCluster1",
"Match": {
"Path": "/api/Action1/{**rest}"
},
"Transforms": [
{ "RequestHeadersCopy": "true" },
{ "RequestHeaderOriginalHost": "true" }
]
},
{
"RouteId": "Service2",
"ClusterId": "ServiceCluster2",
"Match": {
"Path": "/api/Action2/{**rest}"
},
"Transforms": [
{ "RequestHeadersCopy": …Run Code Online (Sandbox Code Playgroud) 目前,我们有多个不在网关后面的 API。公开公开的 API 使用 OpenID Connect 进行身份验证和声明授权。某些 API 仅供内部使用,并且受防火墙保护网络安全。
我们计划在我们的 API 之前设置 Kong Gateway Enterprise。我们应该能够在网关处集中来自公共客户端的令牌验证。我们也可以集中一些基本授权(例如范围)。上游 API 中可能仍需要发生一些逻辑。因此,这些 API 仍然需要了解调用者(客户端和用户)的上下文。
理想情况下,我们希望能够拥有可以公开公开并在内部调用的 API,以避免重复逻辑。我想了解一些安全的方法来让 Kong 实现这一点。我仍然不清楚如何设置网关后面的系统。
我的一些问题是:
其他一些可能有用的注释:
我正在使用 Spring 版本 - 2.4.5
\n应用程序属性:
\nspring.application.name = api-gateway\nserver.port = 8765\n#Had to put the below as I was facing No spring.config.import pro#perty has been defined and this has been put in currency exchang#e, currency converter and naming server as well\nspring.cloud.config.enabled=false \n\neureka.client.service-url.defaultZone = http://localhost:8761/eureka\n\nspring.cloud.gateway.discovery.locator.enabled=true\n\n#Tried the below two, but couldnt resolve the issue\neureka.instance.hostname=localhost\nspring.cloud.gateway.discovery.locator.lower-case-service-id=true\nRun Code Online (Sandbox Code Playgroud)\n所有依赖项均已正确导入。
\nPOM文件
\n<?xml version="1.0" encoding="UTF-8"?>\n<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">\n <modelVersion>4.0.0</modelVersion>\n <parent>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-parent</artifactId>\n <version>2.4.5</version>\n <relativePath/> <!-- lookup parent from repository -->\n </parent>\n <groupId>com.in28minutes.microservices</groupId>\n <artifactId>api-gateway</artifactId>\n …Run Code Online (Sandbox Code Playgroud) 我有一个 HTTP API 网关,它有一个自定义域,其中包含类似映射和一条触发 Lambda 的https://api.example.com/myapi路由。POST /
问题是https://api.example.com/myapi抛出{"message": "Not Found"}并且它仅适用于尾部斜杠https://api.example.com/myapi/。
我怎样才能使它在有斜线和没有斜线的情况下都可以工作,或者在最坏的情况下只在没有斜线的情况下工作?
以下是CloudFormation供参考:
{
"Resources": {
"Webhoook6917ABA8": {
"Type": "AWS::Lambda::Function",
"Properties": {...}
},
"DomainNameEC95A6E9": {
"Type": "AWS::ApiGatewayV2::DomainName",
"Properties": {
"DomainName": "api.example.com",
"DomainNameConfigurations": [
{
"CertificateArn": "arn:***",
"EndpointType": "REGIONAL"
}
]
}
},
"ApiA2E3A7D3": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"Name": "Api",
"ProtocolType": "HTTP"
}
},
"ApiDefaultStageE05BC5D1": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
"ApiId": {
"Ref": "ApiA2E3A7D3"
},
"StageName": "$default",
"AutoDeploy": true
},
"DependsOn": [ …Run Code Online (Sandbox Code Playgroud) 我们目前正在为我们的微服务分析 API 网关,Kong 是可能的候选者之一。我们发现 Kong 支持多种身份验证插件,但所有插件都基于存储在 Kong 数据库本身中的用户。我们需要将此责任委托给我们的自定义身份验证 HTTP 服务,并且不想将这些用户添加到 API 网关数据库中。
我们可以通过AWS API Gateway使用双向SSL功能吗?我们想在实时流应用程序中使用API Gateway作为运动学的代理。
以下是我的要求
客户端向apigateway发出请求,并且apigateway需要将数据放入运动流。
验证客户端的唯一方法是使用两种SSL。我们的客户不支持其他选择。
目前,本地F5负载平衡器为我们完成了这项工作,并且在F5后面运行着许多雄猫,将数据放入运动机中。
我可以使用API Gateway实现相同的功能吗?看起来甚至aws ELB似乎也不支持此选项。
我看了下面的链接,但这是在服务器上对API网关进行身份验证,而不是对客户端进行apigateway身份验证。
问候卡利扬
我有一个可以以多种不同形式接收 JSON 的 lambda 函数。这个想法是通过 API Gateway 接收它。当我测试给定任何形式的 JSON 的函数时,它工作正常。但是,当我尝试通过 API Gateway 对其进行测试时,它失败了,因为该事件为空。
我尝试添加一个空模型映射:
{}
Run Code Online (Sandbox Code Playgroud)
但我仍然得到相同的结果。如何让 API 将主体中的任何类型的 JSON 传递给函数?
谢谢!
编辑
我想使用 Lambda 代理集成,并且我在 AWS 控制台中使用邮递员和 API 网关测试功能进行了测试。我只是在主体和内容类型标头中使用所需的 JSON 执行 POST。
这是我第一次尝试将微服务架构部署到Kubernetes中。刚开始,我正在考虑使用大使作为我的API网关。我也有一个身份验证服务,它可以验证用户并生成JWT令牌,但是,每次调用服务时,我都需要验证此令牌。这代表了一个过载问题(因为API网关每次接收到流量后,都会去到该外部身份验证服务以验证JWT令牌),并且大使没有选择权,可以在不使用外部服务的情况下进行此过滤。
在这种情况下,使用Zuul网关似乎是最好的选择,因为它允许我验证网关内部的JWT令牌(而不是通过Ambassador之类的外部服务)。但是,我不确定将Zuul部署到Kubernetes中会如何工作,因为据我了解,Zuul需要具有服务发现的地址(例如Eureka)。
如果我在Kubernetes集群中部署Zuul,那么它将如何找到我的服务?
例如在本地,因为我以前使用过Eureka,所以没有问题,而且我知道它的地址。另外,我认为在Kubernetes中部署Eureka并不是一个好主意,因为这将是多余的。
如果用Zuul无法做到这一点,是否还有另一个API网关或方法可以让我使用网关来验证令牌,而不是像Ambassador那样依赖于外部身份验证服务?
谢谢。
我刚刚安装了一个具有 Boot Actuator 启动器依赖项的 Spring Cloud Gateway 服务器 (Greenwich.SR2),但无法访问任何 /actuator/gateway 或 /gateway API
我尝试激活并发布端点,但没有成功: management.endpoint.gateway.enabled=true management.endpoints.web.exposure.include=health,gateway
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.6.RELEASE com.example 网关 0.0.1-SNAPSHOT Spring Boot 的网关演示项目
<properties>
<java.version>11</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我承认这是一个 WebFlux+Netty 服务器,但这与我阅读的内容没有任何区别。不过,我一定错过了一些东西。
有什么经验可以分享,有人吗?
api-gateway ×10
kong ×2
spring-boot ×2
api-security ×1
aws-lambda ×1
c# ×1
failover ×1
kubernetes ×1
ms-yarp ×1
netflix-zuul ×1
service ×1
spring ×1
spring-cloud ×1
web-services ×1