How to setup kong plugin chaining

Hello Guys,

We want 2 kong plugins to perform following tasks.

  1. Read the query params and pass it as Headers in the request.
  2. Based on new headers it should redirect the traffic to api endpoint.

First Plugin:
The plugin should pass query params as headers.(region=us)
To perform the above task we already have request-transformer plugin.
Second Plugin:
Read the header (region=us) and redirect the request.
if header has (region=us) then redirect
there are 2 plugins who can do this route-by-header/set-target-host plugins.
Now, my question is how will I assemble these 2 plugins in the same ingress and execute in orders?
If anyone has better solution then that would be great.

Plugin order is determined by two factors:

The plugin priority determines which order a plugin runs in during a phase. A phase is part of request handling, e.g. access for routing the request and body_filter for reading and forwarding the request body. A plugin defines functions to run in one or more phases.

For example, assume you have pluginA with priority 200 and functions for access and body_filter, and pluginB with priority 100 and only an access function. The complete execution order is then:


For your case, all plugins execute only in the access phase. The two plugins that make routing decisions have higher priorities than request-transformer, so the new headers added by request-transformer would not be available to the routing plugins. To work around that, you’d likely want to duplicate request-transformer into a custom plugin with a priority higher than the others (priority higher than 2000), or write your own custom plugin with higher priority.