0

我创建了一个自定义 kong 插件并尝试在本地部署它。尝试使用 Luarocks、Pongo 和手动……但有些人现在能够做到。

分享我在下面遵循的步骤。

命令

luarocks make 

日志

kong-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM) kong-check-x-header 1.0-1 is now installed in /usr/local/Cellar/openresty@1.19.3.2/1.19.3.2/luarocks (license: Apache 2.0)

命令

luarocks pack kong-check-x-header 1.0-1

日志

Packed: /Users/jaikratsinghtariyal/Sandbox/kong-check-x-header/kong-check-x-header-1.0-1.all.rock

命令

luarocks install kong-check-x-header-1.0-1.all.rock

日志

kong-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM)

Error: /usr/local/Cellar/openresty@1.19.3.2/1.19.3.2/luarocks/lib/luarocks/rocks-5.1/kong-check-x-header/1.0-1/lua/kong/plugins/kong-check-x-header/schema.lua: No such file or directory

已经有好几天了...为此苦苦挣扎...需要一些助手。

GITHUB - https://github.com/jaikratsinghtariyal/kong-check-x-header

评论后更新

命令按以下顺序触发。

  • 庞戈包

日志 -

Creating kong-pongo_kong_run ... done

kong-plugin-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM)
Stopping after installing dependencies for kong-plugin-check-x-header 1.0-1

Kong version: 2.5.0

kong-plugin-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM)
kong-plugin-check-x-header 1.0-1 is now installed in /usr/local (license: Apache 2.0)

Packed: /kong-plugin/kong-plugin-check-x-header-1.0-1.all.rock

`

  • pongo 壳
  • luarocks 安装 /kong-plugin/kong-plugin-check-x-header-1.0-1.all.rock

日志:-

kong-plugin-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM) 
kong-plugin-check-x-header 1.0-1 is now installed in /usr/local (license: Apache 2.0)
  • export KONG_PLUGINS=bundled,kong-plugin-check-x-header (我应该提到 kong-plugin-check-x-header 或 check-x-header ......实际上两者都尝试过,但错误更有希望通过检查-x-标题)
  • kong 迁移引导程序
  • 刚开始

除了工作之外的所有命令kong start

日志 -

Error: 
/usr/local/share/lua/5.1/kong/cmd/start.lua:75: /usr/local/share/lua/5.1/kong/cmd/start.lua:64: nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:515: error loading plugin schemas: on plugin 'kong-plugin-check-x-header': kong-plugin-check-x-header plugin is enabled but not installed;
no plugin found
stack traceback:
    [C]: in function 'assert'
    /usr/local/share/lua/5.1/kong/init.lua:515: in function 'init'
    init_by_lua:3: in main chunk

stack traceback:
    [C]: in function 'error'
    /usr/local/share/lua/5.1/kong/cmd/start.lua:75: in function 'cmd_exec'
    /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:88>
    [C]: in function 'xpcall'
    /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:45>
    /kong/bin/kong:9: in function 'file_gen'
    init_worker_by_lua:47: in function <init_worker_by_lua:45>
    [C]: in function 'xpcall'
    init_worker_by_lua:54: in function <init_worker_by_lua:52>
4

1 回答 1

0

首先要使用 pongo 你必须尊重文件路径和插件名称

kong-check-x-header=>kong-plugin-check-x-header

那么你应该把你的文件放在正确的目录中 kong/plugins/check-x-header/

你有kong-check-header-x而不是check-x-header在规范文件中。

我认为您应该使用 linter likepongo lint来检测问题,例如 X-Auth-Token不能用作您应该喜欢的密钥X_Auth_Token

于 2021-09-07T11:22:32.183 回答