Skip to content

Support per-route config for Lua #3124

@salper

Description

@salper

Hi,

I'm trying to implement simple basic auth using LUA, and I want to activate the filter on selected routes. But it seems that I can't get to make per_filter_config on route configuration work. Am I missing something ?

This is working:

- filters:
  - name: envoy.http_connection_manager
    config:
      access_log:
        name: envoy.file_access_log
        config:
          path: /dev/stdout
      codec_type: auto
      stat_prefix: ingress_http
      route_config:
        name: proxy
        virtual_hosts:
          - name: backend
            domains:
              - '*'
            routes:
              - match:
                  prefix: /api
                route:
                  cluster: api
              - match:
                  prefix: /
                route:
                  cluster: web
      http_filters:
        - name: envoy.lua
          config:
            inline_code: |
              function envoy_on_request(request_handle)
                request_handle:respond(
                  {
                    [":status"] = "401",
                    ["Content-Type"] = "text/plain",
                    ["WWW-Authenticate"] = "Basic"
                  },
                  "Please authenticate!"
                )
              end
        - name: envoy.router
          config: {}

But this is not:

- filters:
  - name: envoy.http_connection_manager
    config:
      access_log:
        name: envoy.file_access_log
        config:
          path: /dev/stdout
      codec_type: auto
      stat_prefix: ingress_http
      route_config:
        name: proxy
        virtual_hosts:
          - name: backend
            domains:
              - '*'
            routes:
              - match:
                  prefix: /api
                route:
                  cluster: api
              - match:
                  prefix: /
                per_filter_config:
                  envoy.lua:
                    inline_code: |
                      function envoy_on_request(request_handle)
                        request_handle:respond(
                          {
                            [":status"] = "401",
                            ["Content-Type"] = "text/plain",
                            ["WWW-Authenticate"] = "Basic"
                          },
                          "Please authenticate!"
                        )
                      end
                route:
                  cluster: web
      http_filters:
        - name: envoy.router
          config: {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests. Not bugs or questions.help wantedNeeds help!

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions