[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Annotations for ha-proxy x-forwarded-host



Hi Daniel.

on Donnerstag, 07. September 2017 at 14:30 was written:

> Hi!
>
> We run into an issue with how ha-proxy is re-writing the
> x-forwarded-headers in OpenShift. We have an application that needs
> the original x-forwarded-host header passed in  the request it seems
> that the ha-proxy router is overwriting the ‘X-Forwarded-Host” headers
> to match the requested host-header.
>  
> --- the generated config for my route---
>  
>   http-request set-header X-Forwarded-Host %[req.hdr(host)]
>   http-request set-header X-Forwarded-Port %[dst_port]
>  
> Basically we want to keep the orginial ‘X-Forwarded-Host’, is there
> any way to configure this behavior?


You will need a custom template as described in the doc
https://docs.openshift.org/latest/install_config/router/customized_haproxy_router.html#using-configmap-replace-template

You can then add in the custom template this line, untested.

http-request set-header X-Forwarded-Host %[req.fhdr(X-Forwarded-Host)],%[req.hdr(host)] if { req.fhdr(X-Forwarded-Host) -m found }
http-request set-header X-Forwarded-Host %[req.hdr(host)] if !{req.fhdr(X-Forwarded-Host) -m found }

This solution is based on Patricks example on HAProxy ml
https://www.mail-archive.com/haproxy formilux org/msg26811.html

> Best Regards/Vänliga Hälsningar
> Daniel Svensson
>  
> Product Specialist Linux SITI
> Technical Infrastructure
> IT Delivery Production
> IKEA IT AB
> Phone: +46 (0)766 190 484

-- 
Best Regards
Aleks

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]