如需在安装后配置 Edge,您需要结合使用 .properties
文件和 Edge 实用程序。例如,如需在 Edge 界面上配置 TLS/SSL,您需要修改 .properties
文件以设置必要的属性。对 .properties
文件所做的更改需要您重启受影响的 Edge 组件。
Apigee 将修改 .properties
文件的技术称为“代码与配置”(有时简称为 CwC)。从本质上讲,包含配置的代码是一种基于 .properties
文件中的设置的键值查找工具。在包含配置的代码中,这些键称为“令牌”。因此,如需配置 Edge,您需要在 .properties
文件中设置令牌。
包含配置的代码允许 Edge 组件设置随产品一起提供的默认值,允许安装团队根据安装拓扑覆盖这些设置,然后允许客户覆盖他们选择的任何属性。
如果您将其视为一种层次结构,那么设置的排列顺序如下,其中客户设置的优先级最高,可覆盖安装团队或 Apigee 的任何设置:
- 客户
- 安装程序
- 组件
确定令牌的当前值
在 .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 SSO | 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 |
不适用(使用安装配置文件) |
SymasLDAP | 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 用于标识组件。可能的值包括:
|
设置令牌值
您只能修改 /opt/apigee/customer/application
目录中的 .properties
文件。每个组件在该目录中都有自己的 .properties
文件。例如,router.properties
和 management-server.properties
。如需查看属性文件的完整列表,请参阅 .properties 文件的位置。
如需创建 .properties
文件,请执行以下操作:
- 在编辑器中创建一个新的文本文件。文件名必须与上表中针对客户文件显示的列表一致。
- 将文件的所有者更改为“apigee:apigee”,如以下示例所示:
chown apigee:apigee /opt/apigee/customer/application/router.properties
如果您将运行 Edge 服务的用户从“apigee”用户更改为其他用户,请使用
chown
将所有权更改为运行 Edge 服务的用户。
升级 Edge 时,系统会读取 /opt/apigee/customer/application
目录中的 .properties
文件。这意味着,升级将保留您在组件上设置的所有属性。
如需设置令牌的值,请执行以下操作:
- 修改组件的
.properties
文件。 - 添加或更改令牌的值。以下示例将
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/*
如需向此类列表添加新值,您通常会将新值附加到列表末尾。
- 重启组件:
/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
- (可选)使用
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
属性,并且想知道用于设置该属性的令牌值,请运行以下命令来获取 /opt/apigee/edge-ui/source
目录中相应属性的 grep
:
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
例如,如需在消息处理器上设置名为 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 界面“发送请求”部分中的请求配置转发代理,以及如何配置可选的代理凭据。 如需配置转发代理,请执行以下操作:
- 修改
/opt/apigee/customer/application/ui.properties
并确保该文件归apigee:apigee
所有。 - 添加以下替换项(将值更改为您的特定代理配置):
conf_application_http.proxyhost=proxy.example.com conf_application_http.proxyport=8080 conf_application_http.proxyuser=apigee conf_application_http.proxypassword=Apigee123!
- 保存并重启经典版界面。
在 Apigee 路由器/Nginx 中添加自定义日志格式
在某些情况下,您可能需要更改默认的 Apigee 路由器/Nginx 日志格式或添加变量。如需更新默认的 Apigee 路由器/Nginx 日志格式配置,请执行以下操作:
- 如果
router.properties
文件不存在,请创建一个,路径如下所示:/opt/apigee/customer/application/router.properties
- 将以下内容添加到
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
Nginx 变量列表位于 http://nginx.org/en/docs/varindex.html。
- 重启路由器以应用新配置:
apigee-service edge-router restart
- 检查新的
log_format
配置 (router_new
) 是否已添加到文件/opt/nginx/conf.d/0-default.conf
中:cat /opt/nginx/conf.d/0-default.conf | grep router_new -A 10
- 向 API 代理发送一些 API 请求,并验证文件中的新日志格式
/opt/apigee/var/log/edge-router/nginx/${org}~${env}.${port}_access_log file