reverse-proxy icon indicating copy to clipboard operation
reverse-proxy copied to clipboard

Headers transforms support RegEx

Open specialforest opened this issue 2 years ago • 2 comments

What should we add or change to make your life better?

There are header transforms that allow to remove a specific header or allow specific headers. E.g. RequestHeaderRemove, ResponseHeaderRemove, ResponseHeadersAllowed etc. In cases when I need to remove or allow multiple headers with similar names it would be more convenient to use RegEx.

Why is this important to you?

I need to remove multiple similar headers from a proxied response. E.g. "x-foo-a", "x-foo-b" etc. Now I need to list them one by one either I use ResponseHeaderRemove or ResponseHeadersAllowed.

specialforest avatar Mar 21 '23 17:03 specialforest

Some thoughts on how it can look like:

  1. Keep RequestHeaderRemove/ResponseHeaderRemove as is because of their singular name.
  2. Introduce RequestHeadersRemove/ResponseHeadersRemove transforms. Example format:
Key Value Default Required
RequestHeadersRemove RegEx expression (none) yes
When Success/Always/Failure Success no
  1. RequestHeadersAllowed/ResponseHeadersAllowed already expect a comma separated list of headers. Since header names don't contain special symbols could possibly allow to pass RegEx here. The implementation will check the value passed if it is RegEx or not. Another options would be 3.1. Add another key to switch between the comma separated list and RegEx, e.g. UseRegex: true/false. 3.2. Leave RequestHeadersAllowed/ResponseHeadersAllowed as is and introduce new transforms like RequestHeadersAllowedRegex/ResponseHeadersAllowedRegex/RequestHeadersRemoveRegex/ResponseHeadersRemoveRegex.

specialforest avatar Mar 21 '23 18:03 specialforest

Triage: It should be doable today in custom transforms. We could do it in config, but it comes with complexity of escaping. Given that we would like to see if there is more demand for feature like this -- please upvote top post if you come across this and are interested in the feature. That will help us prioritize. Thanks!

karelz avatar Mar 23 '23 17:03 karelz