Modify request headers?

So, I’m pretty new to envoy/consul ecosystem.

One question I have is whether it’s possible to modify the outgoing request (http) at the proxy before it’s resolved/segmented/routed?

My scenario is that we’re trying to tease apart a service out of a larger system. The routing rules help move move traffic based on the req path. However, not every client is ready to update and they’re owned by other teams etc… We’d prefer if we didn’t have to ask owners there to add custom headers.

I see envoy has a way to add filters or even inline Lua filters that can inspect/modify the req - but is there any guidance on using that with Consul?

Hi @raghur,

Consul does not currently provide a straight-forward way to configure Envoy filters which could perform request manipulation.

I saw the issue you opened on the Consul repo (hashicorp/consul#7475) which contains a bit more context on your request. It sounds like you’re trying to solve an issue where the API is changing, yet no versioning exists to support clients which understand different response formats. You mentioned that requesting service owners add a header (or otherwise) to their requests seems like a hack. However, this is a fairly common way to implement REST API versioning. It gives the clients the freedom to migrate to newer API versions at their own pace. Is this route a definite no-go for you?

Another alternative in lieu of custom filters might be to simply deploy a second, updated version of the API with a different service name (e.g., api-v2) & modify the consumer’s proxy sidecars to use this new version. This isn’t the most ideal as it reduces flexibility in L7 routing since the API version is essentially statically defined in the upstream config, but it should enable the routing scenario you desire.

1 Like