Converting Nginx Configuration to OpenResty Edge

1. Prepare the Nginx configuration

Get the Nginx configuration that needs to be converted, with the entry file nginx.conf, and compress it into a tar.gz package.

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

2. Converting Nginx configuration

2.1 Opening the conversion page

The conversion can be performed using the following two site.

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

2.2 Upload and convert the Nginx configuration

2.3 Downloading conversion results

3. Importing configuration to OpenResty Edge

3.1 Install OpenResty Edge SDK

Home page: https://pypi.org/project/openresty-edge-sdk/

pip3 install openresty-edge-sdk

3.2 Get the openresty-edge-sdk installation directory

pip3 show openresty-edge-sdk

The output looks like this.

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:

Then “/usr/local/lib/python3.6/site-packages” is the path where openresty-edge-sdk is installed.

3.3 Importing configuration

  • Set environment variables
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'
  • Execute the script to import the configuration
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