轉換 Nginx 配置到 OpenResty Edge

1. 準備 Nginx 配置

獲取需要轉換的 Nginx 配置,入口檔案為 nginx.conf,並壓縮成 tar.gz 包。

tar zcvf nginx-conf.tar.gz *.conf

2. 轉換 Nginx 配置

2.1 開啟轉換頁面

可以使用以下兩個介面進行轉換:

  1. https://ngx2edge.openresty.com
  2. https://YOUR-EDGE-ADMIN-HOST/tools/nginx2edge

2.2 上傳並轉換 Nginx 配置

2.3 下載轉換結果

3. 匯入配置到 OpenResty Edge

3.1 安裝 OpenResty Edge SDK

主頁: https://pypi.org/project/openresty-edge-sdk/

pip3 install openresty-edge-sdk

3.2 獲取 openresty-edge-sdk 的安裝目錄

pip3 show openresty-edge-sdk

輸出如:

Name: openresty-edge-sdk
Version: 1.2.15
Summary: OpenResty Edge Python SDK
Home-page: https://www.openresty.com
Author: OpenResty Inc.
Author-email: support@openresty.com
License: UNKNOWN
Location: /usr/local/lib/python3.6/site-packages
Requires: requests, urllib3
Required-by:

則 “/usr/local/lib/python3.6/site-packages” 是 openresty-edge-sdk 的安裝路徑。

3.3 匯入配置

  • 設定環境變數
export EDGE_PYTHON_DIR='/EDGE/PYTHON/SDK/PATH'
export EDGE_HOST='https://YOUR-EDGE-ADMIN-HOST:443'
export EDGE_USER='YOUR-EDGE-ADMIN-USERNAME'
export EDGE_PASSWORD='YOUR-EDGE-ADMIN-PASSWORD'
export EDGE_SSL_VERIFY='True'
  • 執行指令碼匯入配置
python3 /EDGE/PYTHON/SDK/PATH/edge2client/utils/global_ini.py /CONVERSION/RESULT/PATH
python3 /EDGE/PYTHON/SDK/PATH/edge2client/utils/create_apps.py /CONVERSION/RESULT/PATH/apps