Forum Discussion
nitass
Jun 20, 2013Employee
i see. you cannot use HTTP:: in CLIENT_ACCEPTED event. so, you have to collect and parse tcp payload yourself.
e.g.
[root@ve10:Active] config b virtual bar list
virtual bar {
snat automap
destination 172.28.19.252:80
ip protocol 6
rules myrule
}
[root@ve10:Active] config b rule myrule list
rule myrule {
when CLIENT_ACCEPTED priority 100 {
if { ![IP::addr [IP::client_addr] equals 192.0.0.0/8] } {
pool foo
event disable all
} else {
TCP::collect
}
}
when CLIENT_DATA {
if { [scan [TCP::payload] {GET %s HTTP/1.[01]} obj] == 1 } {
switch -glob $obj {
"/*.gif" {
set resp "HTTP/1.0 200 OK\r\nContent-Type: image/gif\r\n\r\n[b64decode [class match -value $obj equals images_class]]"
set resp_bin [binary format a* $resp]
TCP::respond $resp_bin
}
default {
TCP::respond "HTTP/1.0 200 OK"
}
}
TCP::close
}
}
}