How do I install custom plugins in Kong?

What is a Kong plugin?

It's a collection of code that you add to a Kong in order to add functionality.

You can add a plugin by specifying it in your config file. For example, the following config entry adds the plugin test: debugplugin.test=true If you want to see what your plugins are, you can do the following: kong plugins --list. This will list all the plugins. If you want to see the actual plugin configuration, you can do the following: kong plugins --show . This will list the actual configuration and output. The plugins that come with Kong are very basic. We plan to add more plugins in the future, including a full authentication and authorization plugin. You can read more about plugins here.

Plugins are organized into groups. There is a list of all the groups that exist in the admin interface: The default group is default. All plugins will be placed in this group. If you want to add your own plugin, you must add it to the default group.

We recommend that you don't create groups of plugins, but instead just add your plugins to the default group. Adding a Plugin. The following steps show how to add a plugin to Kong. Add the plugin to the plugins directory. Add the plugin to your Kong config file. Start the web server (to make sure the plugin works). When you have verified that your plugin works, you can remove it from your config file. Plugins should be added to the plugins directory. This directory is located at /etc/kong/plugins . This directory contains a directory called for each group of plugins.

For example, plugins for the default group are stored in /etc/kong/plugins/default . In the plugins directory, you can add a plugin by using the kong plugin command. For example, to add the plugin test to the default group: kong plugin add test. This command creates a test directory under the default group.

How to use custom plugin in Kong?

We're using Kong 0.

11.x, and I'm trying to set up a custom plugin for our application that uses the service's custom configuration parameters to determine whether to return true or false for a specific request.

The documentation () recommends using the "Plugin configuration" setting in the API router, but this is where I'm confused. I think what the docs mean is to define the plugin setting as: The default behavior of a plugin is to apply the configured rules to every request, unless another configuration option overrides that default. In that case, only requests which match the rule will be affected. For example, the plugin might have a rule that is conditionally true if an x-auth-token parameter is present. In that case, the plugin will apply its rules to the request only if it matches the token. If the token matches, then the request will be allowed, otherwise it will be denied.

In our case, we'd like to override that behavior so that our plugin only applies its rules to the request if it matches one of the settings we have in our service's custom configuration. I don't see an option for this, however, and am wondering if there is a different/better way to do this? Kong's pluggable architecture is different than the classic plugins in most of the container solutions. That said, there's nothing stopping you from writing your own plugin that does exactly what you want. Here's a simple example of a very basic plugin. You can also use it as a template for developing your own plugin.

Package main. Import (. "fmt". "github.com/kong"

Related Answers

Is Kong API gateway free?

If you're building a service and want to serve web requests to it, you ma...

What are Kong plugins?

You should check the kong terms and conditions, as there is a limit to the free accounts....

Is Kong better than MuleSoft?

The first time we used Kong, we did so in the pre-release and early days....