如何配置 Edge

Edge for Private Cloud v. 4.16.05

如需在安装后配置 Edge,您需要结合使用 .properties 文件和 Edge 实用程序。例如,如需在 Edge 界面上配置 TLS/SSL,您需要修改 .properties 文件以设置必要的属性。对 .properties 文件的更改需要您重启受影响的 Edge 组件。

Apigee 将修改 .properties 文件的技术称为代码与配置。从本质上讲,代码与配置是基于 .properties 文件中的设置的键值对查找工具。在包含配置的代码中,这些键称为令牌。因此,如需配置 Edge,您需要在 .properties 文件中设置令牌。

通过代码和配置,Edge 组件可以设置随产品一起提供的默认值,让安装团队根据安装拓扑替换这些设置,然后让客户替换他们选择的任何属性。

如果将其视为层次结构,则设置会按如下方式排列,其中客户设置具有最高优先级,可覆盖安装程序团队或 Apigee 的任何设置:

  1. 客户
  2. 安装程序
  3. Apigee

如何使用 .properties 文件

作为客户,您只能修改 /<inst_root>/apigee/customer/application 目录中的 .properties 文件。每个组件在该目录中都有自己的 .properties 文件。例如,router.properties 和 management-server.properties。

:
  1. 以任意用户身份在编辑器中创建文件。
  2. 将文件的所有者更改为 apigee:apigee,或者如果您将运行 Edge 服务的用户从 apigee 用户更改为其他用户,请将文件更改为运行 Edge 服务的用户。

如需为组件设置属性,请修改相应的 .properties 文件以设置令牌,然后重启组件:

> /<inst_root>/apigee/apigee-service/bin/apigee-service component restart

例如,修改 router.properties 后,重启路由器:

> /<inst_root>/apigee/apigee-service/bin/apigee-service edge-router restart

升级 Edge 时,系统会读取 /<inst_root>/apigee/customer/application 目录中的 .properties 文件。这意味着,升级将保留您在组件上设置的所有属性。

.properties 文件的位置

Edge 组件的 .properties 文件有三个顶级目录:安装所有者和客户。默认位置如下表所示:

警告:Edge 客户只能修改 /<inst_root>/apigee/customer 下的 .properties 文件。虽然您可以查看组件和安装目录下的文件,但请勿修改任何文件。

所有者

默认令牌根目录

组件

<inst_root>/apigee/<prefix>-<component>/conf

其中 /<prefix>-<component> 标识组件,例如 edge-router 或 apigee-cassandra。

安装

<inst_root>/apigee/token

客户

<inst_root>/apigee/customer

确定代币的当前价值

在组件的 .properties 文件中设置令牌之前,您可以先使用以下命令确定其当前值:

> /<inst_dir>/apigee/apigee-service/bin/apigee-service comp configure -search token

其中,comp 是组件的名称,token 是要检查的令牌。

此命令会搜索 .properties 文件的层次结构,以确定令牌的当前值。

例如,如需检查路由器的 conf_router_HTTP.request.line.limit 令牌的当前值,请运行以下命令:

> /<inst_dir>/apigee/apigee-service/bin/apigee-service edge-router configure -search conf_router_HTTP.request.line.limit

您会在表单中看到输出:

Found key conf_router_HTTP.request.line.limit, with value, 4k, in /opt/apigee/edge-router/token/default.properties

在 .properties 文件中设置令牌

如需替换令牌的值,请执行以下操作:

  1. 修改组件的 .properties 文件以设置令牌值。如果该文件不存在,请创建它。
  2. 重启组件。
  3. 检查令牌值。

例如,如需为 Edge 路由器设置请求行限制,请执行以下操作:

  1. 修改 /<inst_root>/apigee/customer/application/router.properties 文件,以设置 conf_router_HTTP.request.line.limit 令牌:

    conf_router_HTTP.request.line.limit=8k
  2. 重启 Edge Router:

    > /<inst_root>/apigee/apigee-service/bin/apigee-service edge-router restart
  3. 检查令牌的值:

    > /<inst_dir>/apigee/apigee-service/bin/apigee-service edge-router configure -search conf_router_HTTP.request.line.limit

设置接受多个值的令牌

某些令牌接受以英文逗号分隔的值列表。例如,conf_security_rbac.restricted.resources 令牌接受受限 URI 列表,以便只有系统管理员可以调用它们。如需查看 conf_security_rbac.restricted.resources 的值,请运行以下命令:

> cd /<inst_root>/apigee/edge-management-server
> grep -ri "conf_security_rbac.restricted.resources" *

输出包含以下内容:

token/default.properties:conf_security_rbac.restricted.resources=/environments,/environments/*,/environments/*/virtualhosts,/environments/*/virtualhosts/*,/pods,/environments/*/servers,/rebuildindex,/users/*/status

如需设置接受值列表的令牌,请在 .properties 文件中将任何新值附加到令牌的当前值。 因此,如需将 URI /myuri/* 添加到 conf_security_rbac.restricted.resources,请修改 /<inst_root>/apigee/customer/application/management-server.properties 文件,如下所示:

conf_security_rbac.restricted.resources=/environments,/environments/*,/environments/*/virtualhosts,/environments/*/virtualhosts/*,/pods,/environments/*/servers,/rebuildindex,/users/*/status,/myuri/*

查找令牌

在大多数情况下,本指南中会指明您需要设置的令牌。不过,如果您需要确定用于替换属性的令牌,请在组件的 source 文件夹中执行 grep。

例如,如果您知道在之前的 Edge 版本中设置了 session.maxAge 属性,并且想要知道用于设置该属性的令牌值,请在 /<inst_root>/apigee/edge-ui/source 目录中 grep 查找该属性:

> grep -ri "session.maxAge" /<inst_root>/apigee/edge-ui/source

您应该会看到以下形式的结果:

/<inst_root>/apigee/edge-ui/source/conf/application.conf:session.maxAge={T}conf_application_session.maxage{/T}

{T}{/T} 标记之间的字符串是您在 .properties 文件中设置的令牌。

设置当前已注释掉的令牌

Edge 配置文件中的某些令牌已被注释掉。如果您尝试设置已注释掉的令牌,系统会忽略该设置。

如需设置已注释掉的令牌,请使用以下形式的特殊语法:

conf/file.extension+propertyName=propertyValue

例如,您想在 Message Processor 上设置名为 HTTPClient.proxy.host 的属性。然后,您可以使用 grep 查找该属性以确定其令牌:

> cd /opt/apigee/edge-message-processor
> grep -ri "HTTPClient.proxy.host" *

grep 命令会以包含令牌值的形式返回结果。请注意,属性名称已被注释掉,如属性名称上的 # 前缀所示:

source/conf/http.properties:#HTTPClient.proxy.host={T}conf_http_HTTPClient.proxy.host{/T}
token/default.properties:conf_http_HTTPClient.proxy.host=
conf/http.properties:#HTTPClient.proxy.host=

如需设置该属性,请修改 /opt/apigee/customer/application/message-processor.properties,将该属性设置为:

conf/http.properties+HTTPClient.proxy.host=myhost.name.com

请注意,属性名称的前缀为 conf/http.properties+,即包含该属性的配置文件的位置和名称,后跟“+”。

重启消息处理器后,检查文件 /opt/apigee/edge-message-processor/conf/http.properties:

> cat /opt/apigee/edge-message-processor/conf/http.properties

在文件末尾,您会看到以下形式的属性集:

conf/http.properties:HTTPClient.proxy.host=yhost.name.com