My Custom Plugin Is Not Showing in Plugin list

using docker to run the Kong ,I am created the custom Plugin To Validate the header
Key :Test123
---------------------------handler.lua-------------------------------------------
local kong = kong

local CustomPlugin = {
PRIORITY = 1000,
VERSION = “0.1”,
}

function CustomPlugin:access(conf)
CustomPlugin.super.access(self)

– Validate the static header
local header_value = kong.request.get_header(“Key”)

if header_value ~= “Test123” then
– Return an error response if the header is missing or invalid
return kong.response.exit(401, { message = “Unauthorized: Invalid or missing ‘Key’ header” })
end

– If the header is valid, the request will continue to the upstream service
kong.log.debug(“Header validation passed. Continuing to the upstream service.”)
end

return CustomPlugin

--------------------------------------schema--------------------------------------
local typedefs = require “kong.db.schema.typedefs”

return {
name = “custom-plugin”,
fields = {
{ config = {
type = “record”,
fields = {}
}
}
}
}
----------------------------/etc/kong/kong.conf--------------------------------------------
plugins = bundled,custom-plugin

Used cmd
docker cp ./custom-plugin c3b65b77458c:/usr/local/share/lua/5.1/kong/plugins

docker cp ./kong c3b65b77458c:/usr/local/etc

and restart the container but Not working any solution?

@Sivadharani_G Can you please clarify errors or issues with your code? Please expand on “Not working” by providing any logs, errors and full steps to reproduce.

Also, for your information, you can provide code snippets in code format within your question, this makes it much easier for a reader to understand what is code and what is text of your question.

You surround your code with 3 backticks ( ``` ) For example:

local kong = kong

local CustomPlugin = {
PRIORITY = 1000,
VERSION = “0.1”,
}

Hi @rick ,


image

curl -i -X POST
http://localhost:8001/plugins/
\ –data “name=custom-plugin”

Error : {“name”:“schema violation”,“fields”:{“name”:“plugin ‘custom-plugin’ not enabled; add it to the ‘plugins’ configuration property”},“code”:2,“message”:“schema violation (name: plugin ‘custom-plugin’ not enabled; add it to the ‘plugins’ configuration property)”}

Any one Have solution ?

@Sivadharani_G

The error message provides important information. Did you install the custom plugin properly? Please try following this guide for building and installing a custom plugin from scratch. In particular the Deploy Plugin section may be of help to you.