Search code examples
api-gatewayenvoyproxy

Rename the existing http header in envoy


I want to rename the exiting header in envoy configuration but I cant find any related document expect Access header values by name from header modification options where has no response. Is there any solution for this requirement in envoy?


Solution

  • There isn't any built in filter to achieve this requirement, but it is possible with the lua http filter.

       name: envoy.lua
       typed_config:
         "@type": type.googleapis.com/envoy.config.filter.http.lua.v2.Lua
           inline_code: |
             function envoy_on_request(request_handle)
    
             local originalHeader = request_handle:headers():get("A")
    
             if originalHeader then
             -- Use 'replace' instead of 'add' to overwrite any existing value of the target header 
               request_handle:headers():replace("B", originalHeader) 
               request_handle:headers():remove("A")
             end
           end