Forum Discussion
Jeremy_C_Russel
Nimbostratus
Nov 14, 2011Possible issue with an iRule
Greetings all.
I wanted to get some eyes on this particular rule I've setup. The premise is to take urls in the form of http://string.domain.com or http://www.string.domain.com, capture "st...
nitass
Employee
Nov 14, 2011not sure if adding log command is helpful in troubleshooting.
e.g.
[root@ve1023:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
set www ""
if {[regexp {www} [HTTP::host]]} {
scan [HTTP::host] {%[^.].%[^.].%s} www host dom
} else {
scan [HTTP::host] {%[^.].%s} host dom
}
log local0. "[IP::client_addr]:[TCP::client_port]|[HTTP::host]|[HTTP::uri]|$www|$host|$dom"
if {not [regexp {domain|www|wsecure|ssl} $host]} {
log local0. "Caught a MS host $host, redirecting..."
HTTP::redirect "https://www.domain.com/MS/RedirectMS?site=hub&value=$host"
}
}
}
[root@ve1023:Active] config curl -I http://abc.com/test
HTTP/1.0 302 Found
Location: https://www.domain.com/MS/RedirectMS?site=hub&value=abc
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve1023:Active] config
Nov 14 00:40:24 local/tmm info tmm[4766]: Rule myrule : 172.28.65.150:53712|abc.com|/test||abc|com
Nov 14 00:40:24 local/tmm info tmm[4766]: Rule myrule : Caught a MS host abc, redirecting...
[root@ve1023:Active] config curl -I http://www.abc.com/test
HTTP/1.0 302 Found
Location: https://www.domain.com/MS/RedirectMS?site=hub&value=abc
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve1023:Active] config
Nov 14 00:40:31 local/tmm info tmm[4766]: Rule myrule : 172.28.65.150:53713|www.abc.com|/test|www|abc|com
Nov 14 00:40:31 local/tmm info tmm[4766]: Rule myrule : Caught a MS host abc, redirecting...
additionally, i think it would be great if we can avoid using regex. you know it is cpu intensive.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects