Forum Discussion

robellis_205946's avatar
robellis_205946
Icon for Nimbostratus rankNimbostratus
Jun 11, 2015

multiple irule processing

I have 2 irules linked to a virtual server.

 

irule 1 redirects to a local maintenance page if all of the nodes our down.

 

when HTTP_REQUEST { if { [active_members [LB::server pool]] < 1 } { HTTP::respond 200 content [ifile get irif-unavail.htm ] }}

 

irule2 redirects a user to a specific child directory if the the request is for the root web site

 

when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { HTTP::redirect "https://[HTTP::host]/childdir/" } }

 

irule1 works and redirects the user to the maintenance page if the user goes to the childdir irule2 works if the pool members are available. irule1 doesn't work though if the user goes to the root site address

 

I have tried changing the order in the gui and tried adding a lower priority to irule1.

 

Very new to F5's so any help greatly appreciated.

 

1 Reply

  • when request matches multiple actions, it may make an unexpected result.

     case 1
    
    [root@ve11c:Active:In Sync] config  tmsh list ltm rule qux
    ltm rule qux {
        when HTTP_REQUEST {
      HTTP::respond 200
      HTTP::redirect "http://www.google.com"
    }
    }
    [root@ve11c:Active:In Sync] config  curl -I http://172.28.24.10
    HTTP/1.0 200 OK
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve11c:Active:In Sync] config  cat /var/log/ltm
    Jun 11 17:16:21 ve11c err tmm[10748]: 01220001:3: TCL error: /Common/qux  - Operation not supported. Multiple redirect/respond invocations not allowed (line 1)     invoked from within "HTTP::redirect "http://www.google.com""
    
     case 2
    
    [root@ve11c:Active:In Sync] config  tmsh list ltm rule qux
    ltm rule qux {
        when HTTP_REQUEST {
      HTTP::redirect "http://www.google.com"
      HTTP::respond 200
    }
    }
    [root@ve11c:Active:In Sync] config  curl -I http://172.28.24.10
    HTTP/1.0 302 Found
    Location: http://www.google.com
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve11c:Active:In Sync] config  cat /var/log/ltm
    Jun 11 17:17:51 ve11c err tmm[10748]: 01220001:3: TCL error: /Common/qux  - Operation not supported. Multiple redirect/respond invocations not allowed (line 1)     invoked from within "HTTP::respond 200"
    

    you may use "event" command to disable other events after condition matches.

    event

    https://devcentral.f5.com/wiki/iRules.event.ashx