如何設定 Edge

如要在安裝後設定 Edge,請使用 .properties 檔案組合 和邊緣公用程式舉例來說,如要在 Edge UI 上設定 TLS/SSL, .properties 檔案來設定必要的屬性。變更內容 .properties 檔案會要求您重新啟動受影響的 Edge 元件。

Apigee 是指編輯 .properties 檔案的技術,稱為 config (有時縮寫為 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
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
傳統版 UI (不會影響新版 Edge UI) edge-ui /opt/apigee/customer/application/ui.properties
Edge UI (僅限新的 Edge UI;不會影響傳統版 UI) 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 (Cassandra)
  • apigee-openldap (OpenLDAP)
  • apigee-postgresql (PostgreSQL 資料庫)
  • apigee-qpidd (魁北克)
  • apigee-sso (邊緣單一登入)
  • apigee-zookeeper (ZooKeeper)
  • edge-management-server (管理伺服器)
  • edge-management-ui (新版 Edge UI)
  • edge-message-processor (訊息處理器)
  • edge-postgres-server (Postgres 伺服器)
  • edge-qpid-server (快速伺服器)
  • edge-router (邊緣路由器)
  • edge-ui (傳統版 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

    如果將執行 Edge 服務的使用者從「apigee」變更使用者,請使用 chown 將擁有權變更為執行 Edge 的使用者 課程中也會快速介紹 Memorystore 這是 Google Cloud 的全代管 Redis 服務

升級 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 (魁北克)
    • apigee-sso (邊緣單一登入)
    • apigee-zookeeper (ZooKeeper)
    • edge-management-server (管理伺服器)
    • edge-management-ui (新版 Edge UI)
    • edge-message-processor (訊息處理器)
    • edge-postgres-server (Postgres 伺服器)
    • edge-qpid-server (快速伺服器)
    • edge-router (邊緣路由器)
    • edge-ui (傳統版 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 屬性,而且想知道用來設定的符記值, 則 /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}

以下範例顯示 UI 的 session.maxAge 權杖值:

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

{T}{/T} 標記之間的字串是指您可以設定的符記名稱 顯示在 UI 的 .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 UI 的「傳送要求」部分,為要求設定轉送 Proxy

本節說明如何為來自追蹤 UI 的「傳送要求」部分,使用選用的 Proxy 憑證設定轉送 Proxy。如要設定轉送 Proxy,請按照下列步驟操作:

  1. 編輯 /opt/apigee/customer/application/ui.properties,並確認該檔案為 擁有者:apigee:apigee
  2. 新增下列覆寫值 (將值改為特定 Proxy 設定):
    conf_application_http.proxyhost=proxy.example.com
    conf_application_http.proxyport=8080
    conf_application_http.proxyuser=apigee
    conf_application_http.proxypassword=Apigee123!
  3. 儲存並重新啟動傳統 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

    如要查看 Nginx 變數清單,請前往 http://nginx.org/en/docs/varindex.html

  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 Proxy,並驗證檔案中的新的記錄格式
    /opt/apigee/var/log/edge-router/nginx/${org}~${env}.${port}_access_log file