I am looking for assistance with irule structure/ syntax. We are trying to create an irule that will take an https host name and append a www in front of it. For example https://dog.food.com → https://www.dog.food.com . When the connection runs back through the irule it appears to simply drop. Below is what we have been trying:
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] == “dog.food.com”} { HTTP::redirect https://www.dog.food.com[HTTP::uri] } if {[string tolower [HTTP::host]] == “dog.food.com”} { HTTP::redirect https://www.dog.food.com[HTTP::uri] } if {[HTTP::header exists “Cookie”]} { if {[HTTP::cookie exists “F5SSLISBEINGUSED”]} { HTTP::cookie remove “F5SSLISBEINGUSED” } set current_cookies [HTTP::header “Cookie”] HTTP::header replace “Cookie” “$current_cookies; F5SSLISBEINGUSED=ON” } else { HTTP::header replace “Cookie” “F5SSLISBEINGUSED=ON” } }
Any help you can provide is appreciated.
Thanks,
Kevin Pruett
Better format and syntax correction..my apologies.
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] == “dog.food.com”} {
HTTP::redirect [https://www.dog.food.comHTTP::uri]
}
if {[string tolower [HTTP::host]] == “dog2.food.com”} {
HTTP::redirect https://www.dog2.food.com[HTTP::uri]
}
if {[HTTP::header exists “Cookie”]} {
if {[HTTP::cookie exists "F5SSLISBEINGUSED"]} {
HTTP::cookie remove "F5SSLISBEINGUSED"
}
set current_cookies [HTTP::header "Cookie"]
HTTP::header replace "Cookie" "$current_cookies; F5SSLISBEINGUSED=ON"
} else {
HTTP::header replace "Cookie" "F5SSLISBEINGUSED=ON"
}
}
At a minimum you could do something like this:
when HTTP_REQUEST {
if { not ( [HTTP::host] starts_with "www." ) } {
HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
}
}
In any case, if it appears to just drop the connection, in many cases that can be caused by faulty iRule logic. Take a look at the LTM logs.
Kevin,
Thanks for the quick reply. We are going to give it a try shortly. I will post how it goes.
Kevin