如何配置 Edge

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

Apigee 将修改 .properties 文件的技术称为 代码与 配置(有时缩写为 CwC)。从本质上讲,代码与配置是一种基于.properties文件中的设置的键/值查找 工具。在代码与配置中,键称为 令牌。因此,如需配置 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
管理服务器 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-management-ui /opt/apigee/customer/application/management-ui.properties
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/postgresql.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 (Cassandra)
  • apigee-openldap (OpenLDAP)
  • apigee-postgresql(PostgreSQL 数据库)
  • apigee-qpidd (Qpidd)
  • apigee-zookeeper (ZooKeeper)
  • edge-management-server(管理服务器)
  • edge-management-ui(新版 Edge 界面)
  • edge-message-processor(消息处理器)
  • edge-postgres-server(Postgres 服务器)
  • edge-qpid-server (Qpid 服务器)
  • edge-router(边缘路由器)

设置令牌值

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

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

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

    如果您将运行 Edge 服务的用户从 "apigee" 用户更改为其他用户,请使用 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 (Cassandra)
    • apigee-openldap (OpenLDAP)
    • apigee-postgresql(PostgreSQL 数据库)
    • apigee-qpidd (Qpidd)
    • apigee-zookeeper (ZooKeeper)
    • edge-management-server(管理服务器)
    • edge-management-ui(新版 Edge 界面)
    • edge-message-processor(消息处理器)
    • edge-postgres-server(Postgres 服务器)
    • edge-qpid-server (Qpid 服务器)
    • edge-router(边缘路由器)

    例如,在修改 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 目录。

例如,如果您知道要设置 HTTPRequest.line.limit 属性,并且想知道用于设置该属性的令牌值, 请在 grep /opt/apigee/edge-management-server/source 目录中:

grep -ri "HTTPRequest.line.limit" /opt/apigee/edge-management-server/source

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

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

以下示例显示了管理服务器的 HTTPRequest.line.limit 令牌的值:

/opt/apigee/edge-management-server/source/conf/http.properties:HTTPRequest.line.limit={T}conf_http_HTTPRequest.line.limit{/T}

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

设置当前已注释掉的令牌

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

如需设置在 Edge 配置文件中被注释掉的令牌的值,请使用以下形式的特殊 语法:

conf/filename+propertyName=propertyValue

例如,如需在消息处理器上设置名为 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

在新 Edge 界面中启用或停用 HTTP/2 协议

本部分介绍了如何在新的 Edge 界面 (edge-management-ui) 中启用或停用 HTTP/2 协议。

  1. 创建或修改 /opt/apigee/customer/application/management-ui.properties,并确保该文件的所有者是 apigee:apigee。
  2. 添加以下替换项以启用或停用 HTTP/2 协议:
    conf_uebe_disable_http2={true or false}
  3. 保存并重启新的 Edge 界面 (edge-management-ui)。

在 Apigee 路由器/Nginx 中添加自定义日志格式

在某些情况下,您可能需要更改默认的 Apigee 路由器/Nginx 日志格式或 添加变量。如需更新默认的 Apigee 路由器/Nginx 日志格式 配置,请执行以下操作:

  1. 如果 router.properties 文件不存在,请使用以下路径创建一个:
    /opt/apigee/customer/application/router.properties
  2. 将以下内容添加到 router.properties 文件 ,以创建名为 router_new 的新 log_format 配置 :
    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