Forum Discussion

Moinul_Rony's avatar
Moinul_Rony
Icon for Altostratus rankAltostratus
Mar 17, 2014

Want to insert X-Forwarded-for Original Hostname.

One of our virtual server has an irule to rewrite the original incoming URL to a custom URL toward the server.

How can I include the original hostname as a X-Forwarded-For header so that that can be used as well by the application server.

Our iRule:

when HTTP_REQUEST {

if {[HTTP::host] equals "original.hostname.com" } {

 Replace host header value original.hostname.com with custom.hostname.com
HTTP::header replace Host custom.hostname.com

}

}

We would want to insert a X-forwarded-For [original hostname]

Thanks,

2 Replies

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    That option of passing the "X-forwarded-For" header is in an HTTP profile you can create and attach to your virtual server.

     

  • Personally I would not use X-Forwarded-For as it's now a de-facto RFC-header which is used to store an IP address. Here is what you need (chose your own header name);-

    when HTTP_REQUEST {
        if {[HTTP::host] equals "original.hostname.com" } {
             Replace host header value original.hostname.com with custom.hostname.com
            HTTP::header insert X-Forwarded-Host [HTTP::header Host]
            HTTP::header replace Host custom.hostname.com
        }
    }