How do you use the Local Reply Modification feature?
I was reading about the local reply modification feature: https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/local_reply.html?highlight=mapper and was looking to add the mapper to change the HTTP Response text that would be returned in a fault scenario.
mappers:
- filter:
status_code_filter:
comparison:
op: EQ
value:
default_value: 400
runtime_key: key_b
headers_to_add:
- header:
key: "foo"
value: "bar"
append: false
status_code: 401
body:
inline_string: "not allowed"
However, I'm not sure where to add this in the envoy config. I've tried adding this to the top level of envoy.filters.network.http_connection_manager, but I don't think it's the right spot for it, and wasn't sure how to add it to the http_filters section.
I keep getting the following error:
Protobuf message (type envoy.config.bootstrap.v3.Bootstrap reason INVALID_ARGUMENT:(static_resources.listeners[0].filter_chains[0].filters[0]) mappers: Cannot find field.) has unknown fields
Any help would be appreciated, and I can go back to update the docs to make it clearer if needed!
@karthequian I think you're adding it to the wrong place. HCM has local_reply_config and config should be added like below.
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
http_filters:
- name: envoy.filters.http.router
typed_config: {}
local_reply_config:
mappers:
- filter:
status_code_filter:
comparison:
op: EQ
value:
default_value: 400
runtime_key: key_b
headers_to_add:
- header:
key: "foo"
value: "bar"
append: false
status_code: 401
body:
inline_string: "not allowed"
Thank you so much @mk46! Really useful to see the whole config. Will try it today and close this issue!
Hi @karthequian, LMK if you still facing any issue with configuration otherwise we should close this.
Most helpful comment
@karthequian I think you're adding it to the wrong place. HCM has local_reply_config and config should be added like below.