Add custom header to the responses comming out the given Kubernetes application
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: add-custom-header-envoyfilter
namespace: istio-system
spec:
workloadSelector:
labels:
app: httpd-proxy
configPatches:
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
listener:
# portNumber: 80
filterChain:
filter:
name: envoy.filters.network.http_connection_manager
subFilter:
name: envoy.filters.http.router
patch:
operation: INSERT_BEFORE
value:
name: envoy.filters.http.lua
typed_config:
"@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
inlineCode: |
function envoy_on_response(response_handle)
response_handle:logDebug("Adding custom header to the response")
response_handle:headers():add("X-Custom-Header", "1.2.3.4")
end
The above works on the response. To modify the Lua `inlineCode` should look like this
function envoy_on_request(request_handle)
request_handle:logInfo("Received request for " .. request_handle:headers():get(":path"))
end
Note that by default the istio logging level is set to warning. You need to turn loggin to info to make it appear in the log file.
Brak komentarzy:
Prześlij komentarz