转换 Nginx 配置到 OpenResty Edge
1. 准备 Nginx 配置
获取需要转换的 Nginx 配置,入口文件为 nginx.conf,并压缩成 tar.gz
包。
tar zcvf nginx-conf.tar.gz *.conf
2. 转换 Nginx 配置
2.1 打开转换页面
可以使用以下两个界面进行转换:
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