I have the following requirement and was wondering if htransformation could be used to solve it: Traefik receives requests that contain the following header:
X-Forwarded-For: 62.123.23.32:63417, 172.22.0.4
What I would like to do, is add the following header, using the value of X-Forwarded-For:
X-Real-Ip: 62.123.23.32
I was thinking about an approach like:
clone X-Forwarded-For header as X-Real-Ip
using RewriteValueRule tweak the value of X-Real-Ip to only include the first IP address from the list.
What I can't figure out is 1.: I thought I could use Set with HeaderPrefix to reference the value of another header. However, it seems HeaderPrefix is only supported by Join. When using Join however, X-Real-Ip is not set - maybe because Join requires the header to already be there (assumption based on join.go implementation)?
Do you have any thoughts on whether it's feasible to solve the above using htransformation and if so, how?
I have the following requirement and was wondering if
htransformation
could be used to solve it: Traefik receives requests that contain the following header:What I would like to do, is add the following header, using the value of
X-Forwarded-For
:I was thinking about an approach like:
X-Forwarded-For
header asX-Real-Ip
RewriteValueRule
tweak the value ofX-Real-Ip
to only include the first IP address from the list.What I can't figure out is 1.: I thought I could use
Set
withHeaderPrefix
to reference the value of another header. However, it seemsHeaderPrefix
is only supported byJoin
. When usingJoin
however,X-Real-Ip
is not set - maybe becauseJoin
requires the header to already be there (assumption based on join.go implementation)?Do you have any thoughts on whether it's feasible to solve the above using
htransformation
and if so, how?