如何設定 Edge

私有雲 v4.18.05 的邊緣

如要在安裝後設定 Edge,請搭配使用 .properties 檔案和 Edge 公用程式。舉例來說,如要在 Edge UI 上設定 TLS/SSL,您必須編輯 .properties 檔案來設定必要屬性。如要變更 .properties 檔案,您必須重新啟動受影響的 Edge 元件。

Apigee 是指將 .properties 檔案編輯成透過設定進行程式碼的技術。基本上,具有設定的程式碼是一種鍵/值查詢工具,奠基於 .properties 檔案中的設定。在含有設定的程式碼中,金鑰稱為「權杖」。因此,如要設定 Edge,您需要在 .properties 檔案中設定權杖。

具有設定的程式碼可讓 Edge 元件設定與產品一併傳送的預設值,讓安裝團隊依據安裝拓撲覆寫這些設定,然後讓客戶覆寫他們選擇的任何屬性。

若要將此設定視為階層,則設定的順序如下:客戶設定的優先順序最高,以覆寫安裝者團隊或 Apigee 的任何設定:

  1. 客戶
  2. 安裝程式
  3. Apigee

如何使用 .properties 檔案

客戶只能修改 /opt/apigee/customer/application 目錄中的 .properties 檔案。每個元件在該目錄中都有自己的 .properties 檔案。例如 router.propertiesmanagement-server.properties

舉例來說,如要建立 .properties 檔案:

  1. 以任何使用者的身分在編輯器中建立檔案。
  2. 使用 chown 將檔案擁有者變更為「apigee:apigee」,或如果您將執行 Edge 服務的使用者從「apigee」使用者變更為執行 Edge 服務的使用者。

如要設定元件的屬性,請編輯對應的 .properties 檔案來設定權杖,然後重新啟動元件:

/opt/apigee/apigee-service/bin/apigee-service component restart

例如,編輯 router.properties 後,重新啟動路由器:

/opt/apigee/apigee-service/bin/apigee-service edge-router restart

升級 Edge 時,系統會讀取 /opt/apigee/customer/application 目錄中的 .properties 檔案。這表示升級作業會保留您在元件上設定的所有屬性。

.properties 檔案的位置

Edge 元件的 .properties 檔案有三個頂層目錄:安裝項目、擁有者和客戶。預設位置如下表所示:

擁有者 預設權杖根目錄
元件
/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)
安裝
/opt/apigee/token
客戶
/opt/apigee/customer

判斷符記目前的值

在為元件設定 .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

設定 .properties 檔案中的權杖

如何覆寫符記的值:

  1. 編輯元件的 .properties 檔案,設定符記值。如果檔案不存在,請建立一個。
  2. 重新啟動元件。
  3. 請檢查權杖值。

例如,若要設定邊緣路由器的要求行限制:

  1. 編輯 /opt/apigee/customer/application/router.properties 檔案以設定 conf_http_HTTPRequest.line.limit 權杖:
    conf_http_HTTPRequest.line.limit=8k
  2. 重新啟動 Edge Router:
    /opt/apigee/apigee-service/bin/apigee-service edge-router restart
  3. 請檢查權杖值:
    /opt/apigee/apigee-service/bin/apigee-service edge-router configure -search conf_http_HTTPRequest.line.limit

設定具有多個值的符記

部分權杖會以半形逗號分隔值清單。舉例來說,conf_security_rbac.restricted.resources 權杖會取得受限制的 URI 清單,因此只有 sysadmin 才能呼叫這些 URI。若要查看 conf_security_rbac.restricted.resources 的值:

cd /opt/apigee/edge-management-server
grep -ri "conf_security_rbac.restricted.resources" *

輸出結果包含以下內容:

token/default.properties:conf_security_rbac.restricted.resources=/environments,/environments/*,/environments/*/virtualhosts,/environments/*/virtualhosts/*,/pods,/environments/*/servers,/rebuildindex,/users/*/status

如要設定擷取值清單的權杖,請將任何新值附加至 .properties 檔案中權杖目前的值。因此,如要將 URI /myuri/* 新增至 conf_security_rbac.restricted.resources,請編輯 /opt/apigee/customer/application/management-server.properties 檔案,如下所示:

conf_security_rbac.restricted.resources=/environments,/environments/*,/environments/*/virtualhosts,/environments/*/virtualhosts/*,/pods,/environments/*/servers,/rebuildindex,/users/*/status,/myuri/*

找出權杖

在多數情況下,本指南會找出您需要設定的憑證。不過,如果需要判斷用來覆寫屬性的權杖,請在元件的 source 資料夾中執行 grep

舉例來說,如果您知道在先前的 Edge 版本中,設定了 session.maxAge 屬性,並想瞭解用於設定該屬性的權杖值,那麼 /opt/apigee/edge-ui/source 目錄中屬性的 grep 如下:

grep -ri "session.maxAge" /opt/apigee/edge-ui/source

您應該會看到以下形式的結果:

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

{T}{/T} 標記之間的字串是您在 .properties 檔案中設定的權杖。

設定目前已加上註解的符記

部分符記在 Edge 設定檔中已加註。如果您嘗試設定已加上註解的符記,系統會忽略該設定。

如要設定標記註解的符記,請使用特殊語法,格式如下:

conf/file.extension+propertyName=propertyValue

舉例來說,您想要在訊息處理器上設定名為 HTTPClient.proxy.host 的屬性。然後,您會為屬性 grep 來判斷其權杖:

cd /opt/apigee/edge-message-processor
grep -ri "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