如要在安裝後設定 Edge,請搭配使用 .properties 檔案和 Edge 公用程式。舉例來說,如要在新版 Edge UI 上設定 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 |
| 管理伺服器 | 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 代表元件。可能的值包括:
|
設定權杖值
您只能修改 /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(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
- (選用) 使用
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 property,並想瞭解用於設定該屬性的權杖值,請在 /opt/apigee/edge-management-server/source 目錄中找到該屬性的 grep:
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
舉例來說,如要在 Message Processor 上設定名為 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 UI (edge-management-ui) 中啟用或停用 HTTP/2 通訊協定。
- 建立或編輯
/opt/apigee/customer/application/management-ui.properties,並確認檔案擁有者為apigee:apigee。 - 新增下列覆寫設定,啟用或停用 HTTP/2 通訊協定:
conf_uebe_disable_http2={true or false} - 儲存並重新啟動新版 Edge UI (
edge-management-ui)。
在 Apigee 路由器/Nginx 中新增自訂記錄格式
在某些情況下,您可能需要變更預設的 Apigee 路由器/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 Proxy 傳送一些 API 要求,並在檔案中驗證新的記錄格式
/opt/apigee/var/log/edge-router/nginx/${org}~${env}.${port}_access_log file