cancel
Showing results for 
Search instead for 
Did you mean: 

Header insert for lb server ip and tcp port

Bryce_Halkerst1
Nimbostratus
Nimbostratus

Working

 

X-Who-A

 

when HTTP_RESPONSE {

 

set server [string range [LB::server] 2 end]

 

set port [string range [LB::server port] 2 end]

 

HTTP::header insert "X-Who-A" "AN-$server-$port"

 

}

 

 

Header output: X-Who-A AN-ommon/Weblogic_Pool 10.193.83.43 7001

 

Need header output to be AN-83.43-01

 

Tried the follwoing string logic, but website will not load when applied: Client would like to have this inserted into the header to be able to drill down which server app is having issues. Has anyone add any luck implementing?

 

Thanks,

 

Bryce

 

 

when HTTP_RESPONSE {

 

scan [LB::server] {%d.%d.%d.%d} a b c d

 

set port [string range [LB::server port] 2 end]

 

HTTP::header insert "X-Who-A" "AN-$c.$d-$port"

 

5 REPLIES 5

nitass
F5 Employee
F5 Employee
e.g.

 

 

[root@ve10:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.252:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b pool foo list pool foo { members 200.200.200.101:80 {} } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_RESPONSE { scan [IP::remote_addr] {%d.%d.%d.%d} a b c d HTTP::header insert "X-Who-A" "AN-$c.$d-[TCP::remote_port]" } } [root@ve10:Active] config curl -I http://172.28.19.252 HTTP/1.1 200 OK Date: Tue, 12 Mar 2013 15:11:03 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Sat, 27 Oct 2012 03:22:35 GMT ETag: "4183f3-59-f28f94c0" Accept-Ranges: bytes Content-Length: 89 Content-Type: text/html; charset=UTF-8 X-Who-A: AN-200.101-80

nitass
F5 Employee
F5 Employee
you may avoid using a and b variables by using asterisk (*).

 

 

[root@ve10:Active] config b rule myrule list rule myrule { when HTTP_RESPONSE { scan [IP::remote_addr] {%*d.%*d.%d.%d} c d HTTP::header insert "X-Who-A" "AN-$c.$d-[TCP::remote_port]" } }

Bryce_Halkerst1
Nimbostratus
Nimbostratus
Perfect, works great! Thanks for your help!

Bryce_Halkerst1
Nimbostratus
Nimbostratus
All,

 

Not having any issues with the irule outputting the last 2 digits of the server tcp ports. Client changed the ports on the server end, so I need the first 2 digits. See below.

 

Thanks,

 

Bryce

 

 

Last Digits work great

 

rule myrule {

 

when HTTP_RESPONSE {

 

scan [IP::remote_addr] {%*d.%*d.%d.%d} c d

 

HTTP::header insert "X-Who-A" "AN-$c.$d-[TCP::remote_port]"

 

}

 

}

 

 

Tried this logic for the first 2 digits in the header insert. No dice!

 

rule myrule {

 

when HTTP_RESPONSE {

 

scan [IP::remote_addr] {%*d.%*d.%d.%d} a b

 

HTTP::header insert "X-Who-A" "AN-$a.$b-[TCP::remote_port]"

 

}

 

}

Bryce_Halkerst1
Nimbostratus
Nimbostratus
I see the issue, a and be are * out.