Apisix 自定义lua扩展插件生效(docker版)(Apifix custom Lua extension comes into effect (docker version))

启动镜像:

docker-apisix-apisix-1
docker-apisix-web2-1
docker-apisix-web1-1
docker-apisix-grafana-1
docker-apisix-prometheus-1
docker-apisix-apisix-dashboard-1
docker-apisix-etcd-1

1.将自己写的lua脚本上传到 docker-apisix-apisix-1 中 文件下

docker cp auth_local.lua docker-apisix-apisix-1:/usr/local/apisix/apisix/plugins/

2.更改apisix的config.yaml文件,可在映射出来的conf文件中更改,更改完成之后保存退出

cd ${dir}/apisix-docker/example/apisix_conf/
添加到plugins下
plugins:
  - "${系统插件}"
  - authz-yifeng

3.在apisix容器 docker-apisix-apisix-1 中重新加载插件

docker exec -it docker-apisix-apisix-1 /bin/bash
curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT

4.在apisix容器 docker-apisix-apisix-1 中导出json配置文件

curl 127.0.0.1:9090/v1/schema > schema.json

5.把docker-apisix-apisix-1容器中schema.json拷贝到docker-apisix-apisix-dashboard-1容器中的/conf下

docker cp docker-apisix-apisix-1:/usr/local/apisix/schema.json /tmp/schema.json
docker cp docker-apisix-apisix-dashboard-1:/usr/local/apisix-dashboard/conf/schema.json /tmp/schema.json_backup_${date}
docker cp  /tmp/schema.json docker-apisix-apisix-dashboard-1:/usr/local/apisix-dashboard/conf/

6.重启apisix-dashboard容器

docker restart docker-apisix-apisix-dashboard-1

7.然后去web端就可以启用自定义扩展lua插件

————————

Start mirroring:

docker-apisix-apisix-1
docker-apisix-web2-1
docker-apisix-web1-1
docker-apisix-grafana-1
docker-apisix-prometheus-1
docker-apisix-apisix-dashboard-1
docker-apisix-etcd-1

1. Upload the Lua script written by yourself to the file in docker-apis ix-apis ix-1

docker cp auth_local.lua docker-apisix-apisix-1:/usr/local/apisix/apisix/plugins/

2. Change the config. Of apifix Yaml file, which can be changed in the mapped conf file. After the change is completed, save and exit

cd ${dir}/apisix-docker/example/apisix_conf/
添加到plugins下
plugins:
  - "${系统插件}"
  - authz-yifeng

3. Reload the plug-in in the API mix container docker-api mix-api mix-1

docker exec -it docker-apisix-apisix-1 /bin/bash
curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT

4. Export the JSON configuration file in the API mix container docker-api mix-api mix-1

curl 127.0.0.1:9090/v1/schema > schema.json

5.把docker-apisix-apisix-1容器中schema.json拷贝到docker-apisix-apisix-dashboard-1容器中的/conf下

docker cp docker-apisix-apisix-1:/usr/local/apisix/schema.json /tmp/schema.json
docker cp docker-apisix-apisix-dashboard-1:/usr/local/apisix-dashboard/conf/schema.json /tmp/schema.json_backup_${date}
docker cp  /tmp/schema.json docker-apisix-apisix-dashboard-1:/usr/local/apisix-dashboard/conf/

6.重启apisix-dashboard容器

docker restart docker-apisix-apisix-dashboard-1

7. Then go to the web to enable the custom extension Lua plug-in