We have below X-Forwarded configured on our cisco ACE , now we are migrating the VIP to F5 LTM. How we can configure the X-Forwarded in F5 ?
insert-http X-Forwarded-Proto header-value “%is” insert-http X-Forwarded-Port header-value “%is” insert-http X-Forwarded-For header-value “%is”
In the HTTP profile there is a drop-down to enable the insertion of the header. Its literately an easy button on BIG-IP.
Thanks Kai,
Will it take care of IP, port and protocol ?
I think it will only X-Forwarded IP
Create custom HTTP profile and ‘Enable’ X-forwarder. 404 Page not found | BIG-IP Documentation In a GUI its just one click with mouse. in CLI modify global parameter of HTTP profile ltm profile http new-http-x-forward-profile { insert-xforwarded-for enabled }
then apply http profile to yoour virtual-server.
Just notice you also mentioned X-Forward-Proto and X-Forwarded-Port, if you want that you will have to either use a local traffic policy or an iRule. A real easy irule to add those is this.
when CLIENT_ACCEPTED {
if { [PROFILE::exists clientssl] == 1 } {
set protocol "https"
}
else {
set protocol "http"
}
}
when HTTP_REQUEST {
HTTP::header replace X-Forwarded-Proto $protocol
HTTP::header replace X-Forwarded-Port [TCP::local_port]
}
Just notice you also mentioned X-Forward-Proto and X-Forwarded-Port, if you want that you will have to either use a local traffic policy or an iRule. A real easy irule to add those is this.
when CLIENT_ACCEPTED {
if { [PROFILE::exists clientssl] == 1 } {
set protocol "https"
}
else {
set protocol "http"
}
}
when HTTP_REQUEST {
HTTP::header replace X-Forwarded-Proto $protocol
HTTP::header replace X-Forwarded-Port [TCP::local_port]
}
Hi Sabeer Ali,
no
X-Forwarded-For
would just forward the IP. To forward other Information you should use the iRule below…
when CLIENT_ACCEPTED {
if { [PROFILE::exists clientssl] } then {
set client_protocol "https"
} else {
set client_protocol "http"
}
}
when HTTP_REQUEST {
HTTP::header insert "X-Forwarded-For" [IP::client_addr]
HTTP::header insert "X-Forwarded-Proto" $client_protocol
HTTP::header insert "X-Forwarded-Port" [TCP::client_port]
}
Cheers, Kai
Hey Brad, is the “>=” expression required in the case that multiple SSL profiles are used?
Hey Brad, is the “>=” expression required in the case that multiple SSL profiles are used?
yeah, but then I realized “exists” is 0 or 1. Brain was going in two directions.
yeah, but then I realized “exists” is 0 or 1. Brain was going in two directions.
exists vs counting is sometimes hard…
exists vs counting is sometimes hard…
Okay, good to know…
BTW: { [PROFILE::exists clientssl] == 1 } does the same as { [PROFILE::exists clientssl] }, but the later is slightly faster. But on the other hand inserting an “== 1” would make the clause more visible…
Okay, good to know…
BTW: { [PROFILE::exists clientssl] == 1 } does the same as { [PROFILE::exists clientssl] }, but the later is slightly faster. But on the other hand inserting an “== 1” would make the clause more visible…