Forum Discussion
Ivan_38122
Apr 24, 2018Nimbostratus
Sorry but the first iRule was very long to attach the second wich I will explain now:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::header User-Agent]] { "ipad" - "iphone" - "android" - "windows phone" - "windows ce" - "bada" - "bb10" - "blackberry" - "symbinos" - "symbain os" - "symbian" - "java" - "winowsphone" - "windowsce" {
This iRule works very similar than the last iRule, but in this case I used a switch with user agent cases, instead the if and the datagroup list I made in the last example, unfortunatelly this also doesn't works, I activated the logging of all if cases for the mobile user agents, but I receive this output: 01220001: ltm1dmz tmm3[21425] TCL error: /Common/iRule_Portal_v9 - can't read "dest_node": no such variable while executing "log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"" ("; arm line 13) invoked from within "switch -glob [HTTP::host] { "example.com" { HTTP::redirect "; ..." ("android" arm line 3) invoked from within "switch -glob [string tolower [HTTP::header User-Agent]] { "android" - "ipad" - "iphone" - "iPhone" - ..." I can't find why if it matches in the line 3 ANDROID, it doesn't processes the traffic in the switch case, because with this iRule I have the same results of the first iRule with mobile devices, a simple RESETswitch -glob [HTTP::host] {
"example.com" {
HTTP::redirect "www.example.com/ctsMobilePublic/index.jsp"
}
"www.example.com" {
if { [HTTP::uri] equals "/" } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
log "Request: [HTTP::uri] from [IP::client_addr]"
HTTP::redirect "www.example.com/ctsMobilePublic/index.jsp"
} elseif { [class match [HTTP::uri] starts_with "ctsmobile_class"] } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
pool Pool-CTSM
} elseif { [class match [HTTP::uri] starts_with "regmobile_class"] } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
pool Pool-CTSN
} elseif { [class match [HTTP::uri] starts_with "regwebv2mob_class"] } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
pool Pool-CTXPRESSX
}
}
}
default {
switch -glob [HTTP::host] {
"example.com" {
HTTP::redirect "www.example.com/servlet/example/inicio"
}
"www.example.com" {
if { [HTTP::uri] equals "/" } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
log "Request: [HTTP::uri] from [IP::client_addr]"
HTTP::uri /servlet/example/inicio
SSL::disable serverside
pool Pool-SRVLT
In this iRule, I used the expression HTTP::uri /servlet/example/inicio to rewrite the iRule, but it seems that internally it do the request to the real server with the URI:/servlet/example/inicio but in the browser it keeps the URI / : this makes fail some components of the web page,
it only works if the original request is , then it matches with the SRVLT_class and send the request to the Pool-SRVLT, working pretty good.
} elseif { [class match [HTTP::uri] starts_with "SSO_class"] } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
pool Pool-SSOSERVICIOS
} elseif { [class match [HTTP::uri] starts_with "Indic_class"] } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
SSL::disable serverside
pool Pool-Indicadores
} elseif { [class match [HTTP::uri] starts_with "WSIND_class"] } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
pool Pool-WSIND
} elseif { [class match [HTTP::uri] starts_with "CTSN_class"] } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
pool $fcpool
log "Request: [HTTP::uri] from [IP::client_addr]"
pool Pool-CTSN
} elseif { [class match [HTTP::uri] starts_with "SRVLT_class"] } {
HTTP::header insert X-Forwarded-For [IP::remote_addr]
log "Request: [HTTP::uri] from [IP::client_addr]"
log "Sending URI:[HTTP::uri] DEST:$dest_node at $node_ip $node_port"
SSL::disable serverside
pool Pool-SRVLT
}
}
}
}
}
}
I would appreciate a lot any answer or help to fix this issue, I have designed more than 10 iRules without success.
Thanks a lot Ivan