我正在运行一个KONG容器,我想向其中添加一个自定义插件,特别是JWT crafter
我已经下载了插件,但是我不知道如何使它从我的KONG容器开始。因此,如果有人在同一位置或知道要遵循的路线,请提供帮助。

最佳答案

我尝试做同样的事情,但是找不到描述正确的答案。
您可以按以下方式配置简单的helloworld插件:(https://github.com/brndmg/kong-plugin-hello-world)

Docker 主机上的本地“插件”目录结构:

然后,您可以挂载本地/plugins目录,并让kong从/plugins目录加载自定义的'helloworld'插件

1)使用环境变量

$ docker run -d --name kong --network=kong-net \
-e "KONG_DATABASE=cassandra" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
**-e "KONG_LUA_PACKAGE_PATH=/plugins/?.lua" \
-e "KONG_CUSTOM_PLUGINS=helloworld" \ **
...
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
**-v "/plugins:/plugins" \**
-p 8080:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 kong:latest

然后,您可以在http://[kong-url]:8001/上看到已配置的自定义插件
..
"custom_plugins": [
"helloworld"
],
..

2)或者,您可以简单地挂载描述您想要的插件的自定义kong.conf文件。

/etc/kong/kong.conf
plugins = bundled,helloworld,jwt-crafter

(似乎第二个选项对于最新版本的Kong更好,因为“kong_custom_plugin”配置会显示“弃用”警告)

对于JWT手工艺者,https://github.com/foodora/kong-plugin-jwt-crafter
似乎插件维护得不好,因此使用luarocks的安装因错误而失败。
$ luarocks install kong-plugin-jwt-crafter
....
kong-plugin-jwt-crafter 1.0-0 depends on lua-resty-jwt ~> 0.1.10-1 (not installed)

Error: Could not satisfy dependency lua-resty-jwt ~> 0.1.10-1: No results matching query were found.

相反,您可以直接将'resty-jwt'添加到官方docker镜像中,以解决依赖关系,该依赖关系未包含在官方镜像中。并将“JWT Crafter”复制到“/plugins”目录,然后加载。

(在Docker容器内部)
 luarocks install lua-resty-jwt

希望这可以帮助。

关于docker - 如何将自定义kong插件添加到dockerized kong中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50391213/

10-11 03:12