如何配置 Edge

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

Apigee 将 .properties 文件修改为使用 config(有时缩写为 CwC)。从本质上讲,包含“config”命令的代码是 工具基于 .properties 文件中的设置。在带有 config 的代码中,这些键称为 tokens。因此,如需配置 Edge,请在 .properties 中设置令牌 文件。

包含配置的代码可让 Edge 组件设置 产品,允许安装团队根据安装拓扑覆盖这些设置, 然后让客户替换他们选择的任何属性。

如果您将其看作一个层次结构,那么这些设置的排列方式如下: 将具有最高优先级的设置覆盖安装程序团队的任何设置,或 Apigee:

  1. 客户
  2. 安装程序
  3. 组件

确定令牌的当前值

.properties 文件中为令牌设置新值之前, 您应首先使用以下命令确定其当前值:

/opt/apigee/apigee-service/bin/apigee-service component_name configure -search token

其中,component_name 是组件名称,token 是令牌 检查。

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

以下示例检查 conf_http_HTTPRequest.line.limit 的当前值 令牌:

/opt/apigee/apigee-service/bin/apigee-service edge-router configure -search conf_http_HTTPRequest.line.limit

您应该会看到类似如下所示的输出:

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

如果令牌的值以 # 开头,则该值已被注释掉,您必须使用 以特殊语法对其进行更改。如需了解详情,请参阅 设置当前被注释掉的令牌

如果您不知道令牌的全名,请使用 grep 等工具搜索 属性名称或关键字。有关详情,请参阅查找 令牌

属性文件

其中包括可修改和不可修改的组件配置文件。本部分将介绍 文件。

可修改的组件配置文件

下表列出了您可以使用的 Apigee 组件和属性文件 修改以配置这些组件:

组件 组件名称 可编辑的配置文件
Cassandra apigee-cassandra /opt/apigee/customer/application/cassandra.properties
Apigee 单点登录 apigee-sso /opt/apigee/customer/application/sso.properties
管理服务器 edge-management-server /opt/apigee/customer/application/management-server.properties
消息处理器 edge-message-processor /opt/apigee/customer/application/message-processor.properties
apigee-monit apigee-monit /opt/apigee/customer/application/monit.properties
传统版界面(不会影响新的 Edge 界面) edge-ui /opt/apigee/customer/application/ui.properties
Edge 界面(仅限新的 Edge 界面;不影响传统版界面) apigee-management-ui 不适用(使用安装配置文件)
OpenLDAP apigee-openldap /opt/apigee/customer/application/openldap.properties
Postgres 服务器 edge-postgres-server /opt/apigee/customer/application/postgres-server.properties
PostgreSQL 数据库 apigee-postgresql /opt/apigee/customer/application/postgressql.properties
Qpid 服务器 edge-qpid-server /opt/apigee/customer/application/qpid-server.properties
Qpidd 卡 apigee-qpidd /opt/apigee/customer/application/qpidd.properties
路由器 edge-router /opt/apigee/customer/application/router.properties
ZooKeeper apigee-zookeeper /opt/apigee/customer/application/zookeeper.properties

如果您想在其中一个组件配置文件中设置属性,但属性 可以在上面列出的位置进行创建。

此外,您还必须确保属性文件归“apigee”所有用户:

chown apigee:apigee /opt/apigee/customer/application/configuration_file.properties

不可修改的组件配置文件

除了可修改的组件配置文件外,还有一些配置文件 是您无法修改的

信息(不可编辑)文件包括:

所有者 文件名或目录
安装
/opt/apigee/token
组件
/opt/apigee/component_name/conf

其中,component_name 标识组件。可能的值包括:

  • apigee-cassandra(卡桑德拉)
  • apigee-openldap(打开 LDAP)
  • apigee-postgresql(PostgreSQL 数据库)
  • apigee-qpidd(Qpidd)
  • apigee-sso(边缘单点登录)
  • apigee-zookeeper (ZooKeeper)
  • edge-management-server(管理服务器)
  • edge-management-ui(新版 Edge 界面)
  • edge-message-processor(消息处理器)
  • edge-postgres-server(Postgres 服务器)
  • edge-qpid-server (Qpid Server)
  • edge-router(边缘路由器)
  • edge-ui(传统版界面)

设置令牌值

您只能修改 .properties /opt/apigee/customer/application 目录中。每个组件都有自己的 .properties 文件。例如:router.propertiesmanagement-server.properties。如需查看属性文件的完整列表, 请参阅 .properties 文件的位置

如需创建 .properties 文件,请执行以下操作

  1. 在编辑器中创建新的文本文件。文件名必须与 如上表所示。
  2. 将文件的所有者更改为“apigee:apigee”,如以下示例所示:
    chown apigee:apigee /opt/apigee/customer/application/router.properties

    如果您从“apigee”更改了运行 Edge 服务的用户user, 使用 chown,用于将所有权更改为运行 Edge 的用户 服务。

升级 Edge 时,.properties文件 /opt/apigee/customer/application 目录。这意味着升级 并保留您在组件上设置的所有属性。

如需设置令牌的值,请执行以下操作

  1. 修改该组件的 .properties 文件。
  2. 添加或更改令牌的值。以下示例将 conf_http_HTTPRequest.line.limit 属性设置为“10k”:
    conf_http_HTTPRequest.line.limit=10k

    如果令牌具有多个值,请使用英文逗号分隔每个值,如下所示 显示:

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

    要向这样的列表添加新值,您通常需要将新值附加到 列表的位置

  3. 重启组件:
    /opt/apigee/apigee-service/bin/apigee-service component_name restart

    其中 component_name 是以下值之一:

    • apigee-cassandra(卡桑德拉)
    • apigee-openldap(打开 LDAP)
    • apigee-postgresql(PostgreSQL 数据库)
    • apigee-qpidd(Qpidd)
    • apigee-sso(边缘单点登录)
    • apigee-zookeeper (ZooKeeper)
    • edge-management-server(管理服务器)
    • edge-management-ui(新版 Edge 界面)
    • edge-message-processor(消息处理器)
    • edge-postgres-server(Postgres 服务器)
    • edge-qpid-server (Qpid Server)
    • edge-router(边缘路由器)
    • edge-ui(传统版界面)

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

    /opt/apigee/apigee-service/bin/apigee-service edge-router restart
  4. (可选)使用 configure -search 选项。例如:
    /opt/apigee/apigee-service/bin/apigee-service edge-router configure -search conf_http_HTTPRequest.line.limit

    如需详细了解 configure -search,请参阅 确定令牌的当前值

查找令牌

大多数情况下,本指南都会指出您需要设置的令牌。但是,如果您需要 来覆盖您不确定其全名或位置的现有令牌的值,请使用 grep 用于搜索组件的 source 目录。

例如,如果您知道在上一版本的 Edge 中,您将 session.maxAge 属性,并想知道用于设置该属性的令牌值, 然后grep,针对/opt/apigee/edge-ui/source中的资源 目录:

grep -ri "session.maxAge" /opt/apigee/edge-ui/source

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

/opt/apigee/component_name/source/conf/application.conf:property_name={T}token_name{/T}

以下示例显示了界面的 session.maxAge 令牌的值:

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

{T}{/T} 标记之间的字符串是您可以设置的令牌的名称 (在界面的 .properties 文件中)。

设置当前被注释掉的令牌

某些令牌在 Edge 配置文件中已被注释掉。如果您尝试设置 在安装或组件配置文件中注释掉,您的设置将被忽略。

要设置在 Edge 配置文件中注释掉的令牌的值,请使用特殊的 语法:

conf/filename+propertyName=propertyValue

例如,如需设置 Message 上名为 HTTPClient.proxy.host 的属性 处理器,属性的第一个 grep 以确定其令牌:

grep -ri /opt/apigee/edge-message-processor/ -e "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=myhost.name.com

为来自 Trace 界面的“发送请求”部分的请求配置正向代理

本部分介绍了如何为来自 Trace 界面的“发送请求”部分,包含可选的代理凭据。 如需配置转发代理,请执行以下操作:

  1. 修改 /opt/apigee/customer/application/ui.properties 并确保文件 所有者:apigee:apigee
  2. 添加以下替换项(更改特定代理配置的值):
    conf_application_http.proxyhost=proxy.example.com
    conf_application_http.proxyport=8080
    conf_application_http.proxyuser=apigee
    conf_application_http.proxypassword=Apigee123!
  3. 保存并重启传统版界面。

在 Apigee Router/Nginx 中添加自定义日志格式

在某些情况下,您需要更改默认的 Apigee Router/Nginx 日志格式或 添加变量。更新默认的 Apigee Router/Nginx 日志格式 配置:

  1. 如果 router.properties 文件不存在,请使用如下所示的路径创建一个:
    /opt/apigee/customer/application/router.properties
  2. 将以下内容添加到 router.properties 文件中 创建一个新的 log_format 配置,并将其命名为 router_new:
    conf_load_balancing_load.balancing.driver.nginx.global.http.parameters.template.extra=log_format router_new 'time_iso8601\\\\thostname\\\\tremote_addr:remote_port\\\\t'\\\\n\\n 'upstream_addr\\\\trequest_time\\\\t-\\\\t-\\\\t'\\\\n\\n 'status\\\\tupstream_status\\\\trequest_length\\\\t'\\\\n\\n 'body_bytes_sent\\\\t'\\\\n\\n 'request\\\\tupstream_http_x_apigee_message_id\\\\t'\\\\n\\n 'http_user_agent\\\\thost\\thostname-pid-connection-connection_requests\\\\tmy_nginx_var_xff\\t'\\\\n\\n 'upstream_http_x_apigee_fault_flag\\\\tupstream_http_x_apigee_fault_source\\\\tupstream_http_x_apigee_fault_code\\\\t'\\\\n\\n 'upstream_http_x_apigee_fault_policy\\tupstream_http_x_apigee_fault_flow\\tupstream_http_x_apigee_fault_revision\\t'\\\\n\\n 'upstream_http_x_apigee_dp_color\\\\tmy_x_apigee_target_latency\\\\t'\\\\n\\n 'upstream_http_x_apigee_proxy\\\\tupstream_http_x_apigee_proxy_basepath\\\\t'\\\\n\\n 'self_region\\\\tself_pod\\\\tself_color\\\\tssl_protocol\\\\tssl_client_verify\\\\tssl_session_id\\\\tssl_session_reused\\\\tupstream_pod\\\\tupstream_region';\\\\n\\n\n
    conf_load_balancing_load.balancing.driver.nginx.access.log={conf_load_balancing_load.balancing.driver.nginx.log.dir}/{org}~{env}.{port}_access_log router_new

    根据需要更新上述命令中的变量。您可以在 以下文件中 log_format 的配置值:

    /opt/apigee/edge-router/conf/load_balancing.properties

    http://nginx.org/en/docs/varindex.html 显示了 Nginx 变量列表。

  3. 重启路由器以应用新配置:
    apigee-service edge-router restart
  4. 检查新的 log_format 配置是否 (router_new) 已添加到该文件中 /opt/nginx/conf.d/0-default.conf:
        
    cat /opt/nginx/conf.d/0-default.conf | grep router_new -A 10
  5. 向 API 代理发送一些 API 请求并验证文件中的新日志格式
    /opt/apigee/var/log/edge-router/nginx/${org}~${env}.${port}_access_log file