如需在安装后配置 Edge,您可以结合使用 .properties
文件和 Edge 实用程序。例如,如需在 Edge 界面中配置 TLS/SSL,您需要修改 .properties
文件来设置必要的属性。如需更改 .properties
文件,您需要重启受影响的 Edge 组件。
Apigee 是指用于修改 .properties
文件的方法,即包含配置的代码(有时缩写为 CwC)。从本质上讲,包含 config 的代码是一种基于 .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 单点登录 | 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/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
如果您从“apigee”用户更改了运行 Edge 服务的用户,请使用
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+
前缀。这是包含相应属性的配置文件的位置和名称(后跟“+”)。
重启 Message Processor 后,请检查文件 /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 界面的“发送请求”部分的请求配置转发代理。如需配置转发代理,请执行以下操作:
- 修改
/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 Router/Nginx 中添加自定义日志格式
在某些情况下,您需要更改默认的 Apigee Router/Nginx 日志格式或添加变量。如需更新默认的 Apigee Router/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
中的新日志格式