Edge for Private Cloud 4.17.01 版
如要在安裝後設定 Edge,請搭配使用 .properties 檔案和 Edge 公用程式。舉例來說,如要在 Edge UI 上設定 TLS/SSL,請編輯 .properties 檔案,設定必要屬性。變更 .properties 檔案後,您必須重新啟動受影響的 Edge 元件。
Apigee 將編輯 .properties 檔案的技術稱為「程式碼與設定」。基本上,程式碼與設定是根據 .properties 檔案中的設定,進行鍵/值查詢的工具。在含有設定的程式碼中,鍵稱為「權杖」。因此,如要設定 Edge,請在 .properties 檔案中設定權杖。
使用設定的程式碼可讓 Edge 元件設定產品隨附的預設值,讓安裝團隊根據安裝拓撲覆寫這些設定,然後讓客戶覆寫所選的任何屬性。
如果將其視為階層,則設定會按照下列方式排列,其中客戶設定具有最高優先順序,可覆寫安裝程式團隊或 Apigee 的任何設定:
- 客戶
- 安裝程式
- Apigee
如何使用 .properties 檔案
客戶只能修改 /opt/apigee/customer/application 目錄中的 .properties 檔案。每個元件在該目錄中都有自己的 .properties 檔案。例如 router.properties 和 management-server.properties。
- 以任何使用者身分在編輯器中建立檔案。
- 將檔案擁有者變更為 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 檔案有三個頂層目錄:安裝擁有者和客戶。預設位置如下表所示:
警告:Edge 客戶只能修改 /opt/apigee/customer 下的 .properties 檔案。雖然您可以查看元件和安裝目錄下的檔案,但請勿修改任何檔案。
|
擁有者 |
預設權杖根目錄 |
|---|---|
|
元件 |
/opt/apigee/<prefix>-<component>/conf 其中 /<prefix>-<component> 會識別元件,例如 edge-router 或 apigee-cassandra。 |
|
安裝 |
/opt/apigee/token |
|
客戶 |
/opt/apigee/customer |
判斷權杖的目前價值
在 .properties 檔案中設定元件的權杖之前,您可以先使用下列指令判斷其目前的值:
> /opt/apigee/apigee-service/bin/apigee-service comp configure -search token
其中 comp 是元件名稱,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 檔案中設定權杖
如要覆寫權杖的值,請按照下列步驟操作:
- 編輯元件的 .properties 檔案,設定權杖值。如果檔案不存在,請建立檔案。
- 重新啟動元件。
- 檢查權杖值。
舉例來說,如要設定 Edge 路由器要求行限制,請按照下列步驟操作:
- 編輯 /opt/apigee/customer/application/router.properties 檔案,設定 conf_http_HTTPRequest.line.limit 權杖:
conf_http_HTTPRequest.line.limit=8k - 重新啟動 Edge 路由器:
> /opt/apigee/apigee-service/bin/apigee-service edge-router restart - 檢查權杖的值:
> /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=yhost.name.com