Open shmuelarditi opened 3 months ago
UPDATE:
i was able to archive this using a workaround, example:
- name: ip-country-headers
spec:
plugin:
htransformation:
Rules:
- Name: 'Initialize Client-Original-Connecting-Ip'
Header: 'Client-Original-Connecting-Ip'
Value: '' # Setting it to empty
Type: 'Set'
- Name: 'Copy CF-Connecting-Ip'
Header: 'Client-Original-Connecting-Ip'
HeaderPrefix: '^'
Sep: ' ' #cant use empty separators so just use space, it will remove it
Values:
- '^Cf-Connecting-Ip'
Type: 'Join'
result from a dummy service i created on our k8s that prints headers:
"cf-connecting-ip": "176.231.166.59",
"client-original-connecting-ip": "176.231.166.59",
would still appreciate adding this feature to the SET handler, as this workout is working but a bit ugly :)
Hello @shmuelarditi,
Thanks for your interest in this traefik plugin !
Indeed, this workaround exists, and might not be the best solution for this.
Feel free to open a PR to add this new feature in the Set Handler :smile:
I have found that the white space is not "removed", you have use the following code to copy a header to another one:
mw-cf-copy-user-to-X-Forwarded-User:
plugin:
htransformation:
Rules:
- Name: 'Initialize X-Forwarded-User'
Header: 'X-Forwarded-User'
Value: '' # Setting it to empty
Type: 'Set'
- Name: 'Copy cf-Access-Authenticated-User-Email'
Header: 'X-Forwarded-User'
HeaderPrefix: '^'
Sep: ' ' #cant use empty separators so just use space, it will remove it
Values:
- '^Cf-Access-Authenticated-User-Email'
Type: 'Join'
- Name: 'Remove empty space'
Header: 'X-Forwarded-User'
Value: ' (.*)'
ValueReplace: '$1'
Type: 'RewriteValueRule'
Hi, @tomMoulard first of all thanks for creating this plugin we are using it in a few places and its great.
we would be happy if we could set an header based on another header value, for example using:
it will be a great and very useful addition, and considering there is similar logic in the Join handler i hope it wont be much work.