api-gatewaykongkong-plugin

Specify which plugins to use on a route in Kong dbless mode


In dbless mode on kong we can specify which routes to be added on plugin using this declration:

plugins:
- name: jwt
  route: <route>
  config: 
    secret_is_base64: false

But I need to specify which plugins this route is going to use with something like:

route:
- name: getUser
  paths:
    - /user
  plugins: [<plugin1>, <plugin2>]

Any way to do this? I dont want to update all the plugin declarations everytime I add a new API on a service.


Solution

  • You can declare your plugins like this:

    services:
    - connect_timeout: 60000
      host: alb.host.dev
      name: service1
      routes:
      - hosts:
        - api.host.com
        - www.host.com
        name: my_host
        methods:
        - GET
        paths:
        - /user
        plugins: 
        - name: plugin1
          config:
            redis_database: 0
            redis_host: redis.dev
            redis_password: null
            redis_port: 6379
            redis_timeout: 2000
        - name: plugin2
          config:
            foo: 1
            bar: 2