設定檔錯誤

您目前查看的是 Apigee Edge 說明文件。
前往 Apigee X 說明文件
info

問題

Edge Router 是使用 NGINX 實作。在 Edge 升級程序中,或變更 Router 的設定時,可能會看到 NGINX 設定錯誤。發生這些錯誤時,Edge 會將導致問題的所有 NGINX 設定檔標示為 /opt/nginx/conf.d

-rw-r--r-- 1 apigee apigee 522 Jul 20 08:41 0-default.conf.bad 
-rw-r--r-- 1 apigee apigee 577 Jul 20 08:42 0-fallback.conf 
-rw-r--r-- 1 apigee apigee 1062 Jul 20 08:18 0-map.conf 
-rw-r--r-- 1 apigee apigee 1887 Jul 20 08:42 custorg_test_default.conf.bad

錯誤訊息

系統不會顯示任何錯誤訊息。不過,由於設定檔有誤,您可能無法執行 API Proxy。

可能原因

通常 NGINX 設定檔會標示為不良,是因為在 /opt/apigee/customer/application/router.properties 檔案中,NGINX 屬性設為不正確的值,或是虛擬主機的變更不正確。

診斷

  1. /opt/nginx/conf.d 目錄中的檔案名稱移除 .bad 後置字元,讓檔案名稱以 .conf 結尾。
  1. 執行 NGINX configtest 工具,判斷失敗原因:
    /opt/nginx/scripts/apigee-nginx configtest

解析度

  1. 如果設定測試指出設定檔有問題的原因,請在 /opt/apigee/customer/application/router.properties 檔案或虛擬主機中,對特定資源進行適當變更,修正問題。
  1. 移除 /opt/nginx/conf.d 目錄:
    rm -rf /opt/nginx/conf.d
  1. 重新啟動路由器:
    /opt/apigee/apigee-service/bin/apigee-service edge-router restart
  1. /opt/nginx/conf.d 目錄中不應再顯示錯誤的設定檔。

如果問題仍未解決,請與 Apigee Edge 支援團隊聯絡。

以下範例說明如何根據 NGINX 設定測試提供的資訊修正問題。

範例 1:為 NGINX 屬性設定的值不正確

  1. 假設您在 /opt/apigee/customer/application/router.properties 檔案中將「proxy_busy_buffers_size」proxy_busy_buffers_size屬性更新為 128K,如下所示:
    conf_load_balancing_load.balancing.driver.proxy.busy.buffer.size=128k 

這導致設定檔在 /opt/apigee/nginx/conf.d 目錄中標示為不良。

  1. 執行 NGINX configtest 指令,判斷失敗原因:
    /opt/nginx/scripts/apigee-nginx configtest
    nginx: [emerg] "proxy_busy_buffers_size" must be equal to or greater than the maximum of the value of "proxy_buffer_size" and one of the "proxy_buffers" in /opt/nginx/conf/nginx.conf:47
    nginx: configuration file /opt/nginx/conf/nginx.conf test failed

設定測試結果指出,proxy_busy_buffers_size 屬性的值應大於或等於 proxy_buffer_size,但似乎設為不正確的值。

  1. 檢查 0-default.conf 檔案中為 proxy_buffer_sizeproxy_busy_buffers_size 屬性設定的值:
    proxy_buffer_size 512k;
    proxy_busy_buffers_size 128k;
  1. /opt/apigee/customer/application/router.properties 檔案中,將 proxy_busy_buffers_size 的值更新為 512K:
    conf_load_balancing_load.balancing.driver.proxy.busy.buffer.size=512k
  1. 移除 /opt/nginx/conf.d 資料夾:
    rm -rf /opt/nginx/conf.d
  1. 重新啟動路由器:
    /opt/apigee/apigee-service/bin/apigee-service edge-router restart

問題已修正,並移除了錯誤的設定檔。

範例 2:程序無法升級 NGINX (僅限 Private Cloud 18.01)

假設您執行 configtest,並收到下列回應:

/apigee-nginx configtest

 nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
 nginx: [emerg] zero size shared memory zone "perclient"
 nginx: configuration file /opt/nginx/conf/nginx.conf test failed

這項失敗表示程序無法將 NGINX 從 1.10.x 升級至 1.12.x。 將 Edge Private Cloud 升級至 18.01 版時,會發生已知錯誤。

如要正確診斷這個問題 (僅限 Private Cloud 18.01),請按照下列步驟操作:

rpm -aq | grep apigee-nginx

這個指令應會傳回已安裝的 rpm,版本為 1.12.x。如果沒有,請按照下列步驟操作:

  1. 停止邊緣路由器元件。
  2. 備份邊緣路由器元件。
  3. 執行下列指令,升級至 apigee-nginx 1.2.x:
  4. sudo yum update apigee-nginx
  5. 刪除 /opt/apigee/nginx/conf.d. 下的所有 *.bad 檔案
  6. 重新啟動邊緣路由器元件。