【问题标题】:One Apigee Api Proxy with a different target endpoint for each environment一个 Apigee Api 代理,每个环境具有不同的目标端点
【发布时间】:2014-05-20 22:21:12
【问题描述】:

我是 Apigee 新手。

我们的主机名中有我们的环境,例如:

something.int.other.thing.co.uk
something.test.other.thing.co.uk
something.stage.other.thing.co.uk
something.prod.other.thing.co.uk

我希望能够将它们映射到 apigee api 代理本身的 4 个环境,分别为 int、test、stage、prod

我目前为他们准备了一个 Rest 资源,例如:/resource

基本上,我希望 apigee api 代理具有一个休息资源,以映射到 4 个不同的目标端点,具体取决于环境。

到目前为止,我已尝试从 UI 中执行此操作,但无法这样做。

我一直在阅读文档,到目前为止我已经找到了这些:

  • 据此应该可以: “一个 API 代理可以包含零个或多个 TargetEndpoints。” (目标端点部分)

http://apigee.com/docs/api-services/content/api-proxy-configuration-reference

  • 根据这些,您可以将路由规则制作到代理端点,但我一直无法将其实现到目标端点:

Create a New Endpoint on an existing API Proxy with "No Target Endpoint"

One API proxy calling two different target endpoints

我也尝试按照这个思路为 TargetEndpoint 做一些事情,在那里我测试了环境名称,但它没有工作:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
    <Description/>
    <Flows/>
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <HTTPTargetConnection>
        <URL>something.int.other.thing.co.uk</URL>
    </HTTPTargetConnection>
    <RouteRule name="int">
        <Condition>environment.name == "int"</Condition>
        <TargetEndpoint>something.int.other.thing.co.uk</TargetEndpoint>
    </RouteRule>
    <RouteRule name="test">
        <Condition>environment.name == "test"</Condition>
        <TargetEndpoint>something.test.other.thing.co.uk/</TargetEndpoint>
    </RouteRule>
    <RouteRule name="stage">
        <Condition>environment.name == "stage"</Condition>
        <TargetEndpoint>something.stage.other.thing.co.uk/</TargetEndpoint>
    </RouteRule>
    <RouteRule name="prod">
        <Condition>environment.name == "prod"</Condition>
        <TargetEndpoint>something.prod.other.thing.co.uk</TargetEndpoint>
    </RouteRule>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
</TargetEndpoint>

那么这可能吗?

你能告诉我怎么做吗?

我们正在迁移到 Apigee,我们的截止日期很紧迫,因此我们将不胜感激!

谢谢!

【问题讨论】:

  • 你的解决方案是什么?
  • Apigee 目标服务器,请参阅下面选择的解决方案评论。

标签: api rest environment-variables backend apigee


【解决方案1】:

Apigee 支持 Target Servers 的概念 - 它从代理中抽象出后端主机,并提供负载平衡。可以将相同的目标服务器配置为针对每个环境指向不同的主机(此概念已内置于 Apigee)。

看看,这应该会有所帮助。

斯里坎特

【讨论】:

  • 非常感谢您的回复!我看到了这些:apigee.com/docs/api/api_methods/232-create-a-targetserverapigee.com/docs/api-services/content/…1) 我们公司有很多团队,据我所知,我们目前都在同一个组织下。如果我将目标服务器和运行状况监视器创建到示例 url,例如:api.enterprise.apigee.com/v1/o{org_name}/environments/test/targetservers 这并不意味着其他团队可以访问它们,并且可能会更改它们的配置,或者删除它们?
  • 2) 我们公司也在为 Apigee 颁发 SSL 证书,在设置目标服务器时是否需要考虑这一点。如果是这样,以什么方式?
  • 3) 从上面的链接我无法弄清楚如何进行 HealthMonitor 配置。您将 LoadBalancer 和 HealthMonitor 配置卷曲到哪些 url?
【解决方案2】:

LoadBalancer 和 TargetServer 设置在 TargetEndpoint 定义中,特别是在 HTTPTargetConnection 元素中。

在此处查看示例:

http://apigee.com/docs/api-services/content/load-balancing-across-backend-servers

如果您确实想将 TargetEndpoint 定义卷曲到您的 API 代理,请查看以下示例脚本以查看有效的 API 调用:

https://github.com/apigee/api-platform-samples/blob/master/tools/proxy_gen.sh

此脚本向您展示如何创建 API 代理并通过 API 调用更新 ProxyEndpoint 和 TargetEndpoints。

【讨论】:

  • 非常感谢您的回复!
猜你喜欢
  • 2014-05-12
  • 1970-01-01
  • 1970-01-01
  • 2014-10-21
  • 2014-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-29
相关资源
最近更新 更多