Forum Discussion

Mahjouboi's avatar
Mahjouboi
Icon for Nimbostratus rankNimbostratus
Dec 07, 2023

iRule not get triggered.

Hi Experts,

I'm facing an issue which I want your kind assistance, I will explain the issue in details, so please excuse me for being so long.

in our environment we have an application working in port 80 and 8080, so I have two VS's in port 80 and 8080, both VS's associated with the same pool members, and both VS's have below iRule for redirection:

when HTTP_REQUEST {
if { [HTTP::host] contains "abc" and [HTTP::path] eq "/" } {
HTTP::redirect "http://abc.xyz.com/otcs/cs.exe?func=llworkspace"
}
}

the application working fine since years, recently I have been requested to use ssl certificate for this app, so I did below steps:

1- created two VS's in port 443 and 8443, with the same IP's which used in port 80 and 8080 and same pool members.

2- assigned the ssl certificate to VS in port 443.

3- disabled the old VS's (80 & 8080).

4- assigned below iRule for redirection:

when HTTP_REQUEST {
if { [HTTP::host] contains "and" and [HTTP::path] eq "/" } {
HTTP::redirect "https://abc.xyz.com/otcs/cs.exe?func=llworkspace"
}
}

During testing, I observed the redirection is not happening, the aim of this redirection to allow the users only to write abc and hit enter, then he should be able to open the full url.

some friends suggested to use or instead of and in the iRule, which am still confuse.

please your advice and guidance.

2 Replies

  • First thing I would do is check if the HTTP_REQUEST event is triggered at all. Try adding some logging to the iRule and check /var/log/ltm to see if the event is triggered.

    when HTTP_REQUEST {
        log local0. "DEBUG: HTTP_REQUEST"
        log local0. "DEBUG: [HTTP::host]"
        log local0. "DEBUG: [HTTP::path]"
    
        if { [HTTP::host] contains "and" and [HTTP::path] eq "/" } {
            HTTP::redirect "https://abc.xyz.com/otcs/cs.exe?func=llworkspace"
        }
    }
  • it seems you have typo

    your new irules for https vs is:
    ...
    if { [HTTP::host] contains "and" and [HTTP::path] eq "/" } {

    while the old irules is:
    ...
    if { [HTTP::host] contains "abc" and [HTTP::path] eq "/" } {