标签: api-gateway

从 Secrets Manager 映射 AWS API GateWay HTTPIntegration 标头

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

amazon-web-services aws-api-gateway api-gateway

5
推荐指数
0
解决办法
515
查看次数

Microsoft C# .NET YARP 504 网关错误和故障转移

我使用 Microsoft C# .NET YARP作为 ASP.NET Core Web API(最新版本)以及 Swagger 和 Kestrel 前面的 API 网关。YARP 用于到许多微服务的内部重定向。

问题:

  1. 对于执行超过大约 504 的请求,我面临 504 http API 网关错误。距 swagger UI 2 分钟。如何设置更长的超时时间?

例如:https://URL/swagger/index.html => 执行 POST FUNCTION => YARP_API_GATEWAY => SERVICE_API_PORT

  1. 如果内部服务目标(端点)因任何原因关闭,如何将“故障转移”配置到另一个目标?

前任。配置:

   "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)

c# failover api-gateway ms-yarp

5
推荐指数
1
解决办法
2457
查看次数

如何保护 Kong 网关后面的 API 的公共和内部流量

目前,我们有多个不在网关后面的 API。公开公开的 API 使用 OpenID Connect 进行身份验证和声明授权。某些 API 仅供内部使用,并且受防火墙保护网络安全。

我们计划在我们的 API 之前设置 Kong Gateway Enterprise。我们应该能够在网关处集中来自公共客户端的令牌验证。我们也可以集中一些基本授权(例如范围)。上游 API 中可能仍需要发生一些逻辑。因此,这些 API 仍然需要了解调用者(客户端和用户)的上下文。

理想情况下,我们希望能够拥有可以公开公开并在内部调用的 API,以避免重复逻辑。我想了解一些安全的方法来让 Kong 实现这一点。我仍然不清楚如何设置网关后面的系统。

我的一些问题是:

  • 我们应该同时拥有内部网关和外部网关吗?是否有关于如何选择何时创建单独网关的指导?
  • 如果我们在一条链中有多个上游服务,如何传递身份验证上下文?
    • 自定义标头?
    • 传递原始 JWT 吗?
  • 如何让服务安全地响应内部和外部调用?
    • 我们可以设置一个网格并使用 mTLS,但是 mTLS 和网关之间传递身份验证上下文的方法不会有所不同吗?
    • 我们可以从 Kong 设置自定义标头,并让其他内部服务也渲染它们。但由于这不在智威汤逊中,我们是否会失去声明的真实性?
    • 我们可以让每个调用者(包括内部服务)获得自己的令牌,但这可能会使客户端和机密的数量难以管理。另外,它无法处理这些服务仍然代表用户作为早期请求的一部分进行操作的情况。
    • 或者我们可以继续保持内部和外部服务分开,但重复一些逻辑。

其他一些可能有用的注释:

  • 除了我们的 OIDC 提供商之外,没有其他现有的 PKI。
  • 服务不会全部被容器化。想想 EC2 上的 IIS。
  • 服务大多是 REST 式的。

web-services microservices kong api-gateway api-security

5
推荐指数
1
解决办法
1408
查看次数

API 网关不起作用。抛出 java.net.UnknownHostException:无法解析

我正在使用 Spring 版本 - 2.4.5

\n

应用程序属性:

\n
spring.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\n
Run Code Online (Sandbox Code Playgroud)\n

所有依赖项均已正确导入。

\n

POM文件

\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)

service spring spring-boot microservices api-gateway

5
推荐指数
1
解决办法
8020
查看次数

HTTP API 网关尾部斜杠

我有一个 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)

amazon-web-services api-gateway

5
推荐指数
0
解决办法
936
查看次数

Kong API Gateway 中的自定义身份验证服务

我们目前正在为我们的微服务分析 API 网关,Kong 是可能的候选者之一。我们发现 Kong 支持多种身份验证插件,但所有插件都基于存储在 Kong 数据库本身中的用户。我们需要将此责任委托给我们的自定义身份验证 HTTP 服务,并且不想将这些用户添加到 API 网关数据库中。

authentication kong api-gateway

4
推荐指数
2
解决办法
8197
查看次数

使用AWS API Gateway的两种SSL

我们可以通过AWS API Gateway使用双向SSL功能吗?我们想在实时流应用程序中使用API​​ Gateway作为运动学的代理。

以下是我的要求

客户端向apigateway发出请求,并且apigateway需要将数据放入运动流。

验证客户端的唯一方法是使用两种SSL。我们的客户不支持其他选择。

目前,本地F5负载平衡器为我们完成了这项工作,并且在F5后面运行着许多雄猫,将数据放入运动机中。

我可以使用API​​ Gateway实现相同的功能吗?看起来甚至aws ELB似乎也不支持此选项。

我看了下面的链接,但这是在服务器上对API网关进行身份验证,而不是对客户端进行apigateway身份验证。

https://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-client-side-ssl-authentication.html

问候卡利扬

aws-api-gateway api-gateway

4
推荐指数
1
解决办法
2408
查看次数

将事件从 API 网关传递到 Lambda

我有一个可以以多种不同形式接收 JSON 的 lambda 函数。这个想法是通过 API Gateway 接收它。当我测试给定任何形式的 JSON 的函数时,它工作正常。但是,当我尝试通过 API Gateway 对其进行测试时,它失败了,因为该事件为空。

我尝试添加一个空模型映射:

{}
Run Code Online (Sandbox Code Playgroud)

但我仍然得到相同的结果。如何让 API 将主体中的任何类型的 JSON 传递给函数?

谢谢!

编辑

我想使用 Lambda 代理集成,并且我在 AWS 控制台中使用邮递员和 API 网关测试功能进行了测试。我只是在主体和内容类型标头中使用所需的 JSON 执行 POST。

在此处输入图片说明

amazon-web-services aws-lambda api-gateway

4
推荐指数
1
解决办法
8702
查看次数

Kubernetes中的Zuul部署

这是我第一次尝试将微服务架构部署到Kubernetes中。刚开始,我正在考虑使用大使作为我的API网关。我也有一个身份验证服务,它可以验证用户并生成JWT令牌,但是,每次调用服务时,我都需要验证此令牌。这代表了一个过载问题(因为API网关每次接收到流量后,都会去到该外部身份验证服务以验证JWT令牌),并且大使没有选择权,可以在不使用外部服务的情况下进行此过滤。

在这种情况下,使用Zuul网关似乎是最好的选择,因为它允许我验证网关内部的JWT令牌(而不是通过Ambassador之类的外部服务)。但是,我不确定将Zuul部署到Kubernetes中会如何工作,因为据我了解,Zuul需要具有服务发现的地址(例如Eureka)。

如果我在Kubernetes集群中部署Zuul,那么它将如何找到我的服务?

例如在本地,因为我以前使用过Eureka,所以没有问题,而且我知道它的地址。另外,我认为在Kubernetes中部署Eureka并不是一个好主意,因为这将是多余的。

如果用Zuul无法做到这一点,是否还有另一个API网关或方法可以让我使用网关来验证令牌,而不是像Ambassador那样依赖于外部身份验证服务?

谢谢。

kubernetes microservices netflix-zuul api-gateway

4
推荐指数
1
解决办法
1975
查看次数

无法将执行器启用到 spring 云网关格林威治

我刚刚安装了一个具有 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 服务器,但这与我阅读的内容没有任何区别。不过,我一定错过了一些东西。

有什么经验可以分享,有人吗?

spring-boot spring-cloud spring-boot-actuator api-gateway

4
推荐指数
1
解决办法
2801
查看次数