Forum Discussion

Ram_75191's avatar
Ram_75191
Icon for Nimbostratus rankNimbostratus
Dec 11, 2013

Notification page for selective URI's (F5 load balancer (version 11.2.1)

Hi, We want to show a Notification page for some of the URI's before the user sees the login page. Here are the scenarios: https:///A https:///B https:///C https:///D We want the users coming into URI's A and B to see a the notification page before taking them to the login page. We should be able to enable or disable this notification page based on the scheduled events. I need help to implement this using iRules. Has anyone implemented something similar?

 

Thanks RI

 

2 Replies

  • Christian_30338's avatar
    Christian_30338
    Historic F5 Account

    hello, are you using the F5 Access Policy Manager (APM) product for the logon pages and authentication? If you are then you can use the "Landing URI" option in the VPE to display a notification / message for some URI's.

     

  • Hi All - Thank you for your responses. Here is the iRule that worked for us.

    when RULE_INIT { set static::debug 0 set static::cookie_expire_time 86400 set static::refresh_time 10 set static::notification_page " Site unavailable" } when HTTP_REQUEST { set mod_path [lindex [split [string trim [string tolower [HTTP::path]] "/"] "/"] 0]

    if { $static::debug } { 
        log local0. "The variable mod_path is: $mod_path"
        log local0. "Refresh Time: $static::refresh_time"
    }
    
    switch $mod_path {
        "aaaaaaa" -
        "bbbbbbb" -
        "ccccccc" {
            if { $static::debug } {
                log local0. "Matched aaaaaaa pool!"
            }
            pool http_pool      
            }
        "ddddddd" {
            if { (not [HTTP::cookie exists NotificationDone]) } {
                if { $static::debug } {
                    log local0. "Cookie was not set in ddddddd! Setting cookie!"
                }
                HTTP::respond 200 content [subst $static::notification_page] Mime-Type "text/html" Set-Cookie "NotificationDone=[clock seconds]; path=/; domain=.[HTTP::host]"
            } elseif { [eval [[clock seconds] - [HTTP::cookie value "NotificationDone"]]] > $static::cookie_expire_time } {
                if { $static::debug } {
                    log local0. "CNotification Done Value: [HTTP::cookie value "NotificationDone"] Expire Time: $static::cookie_expire_time"
                }
                HTTP::cookie remove "NotificationDone"
                HTTP::respond 200 content [subst $static::notification_page] Mime-Type "text/html" Set-Cookie "NotificationDone=[clock seconds]; path=/; domain=.[HTTP::host]"
            }
            pool http_pool      
            }
        "" -
        "eeeeeeee" {
            if { (not [HTTP::cookie exists NotificationDone]) } {
                if { $static::debug } {
                    log local0. "Cookie was not set in eeeeeee! Setting cookie!"
                }
                HTTP::respond 200 content [subst $static::notification_page] Mime-Type "text/html" Set-Cookie "NotificationDone=[clock seconds]; path=/; domain=.[HTTP::host]"
            } elseif { [eval [[clock seconds] - [HTTP::cookie value "NotificationDone"]]] > $static::cookie_expire_time } {
                if { $static::debug } {
                    log local0. "CNotification Done Value: [HTTP::cookie value "NotificationDone"] Expire Time: $static::cookie_expire_time"
                }
                HTTP::cookie remove "NotificationDone"
                HTTP::respond 200 content [subst $static::notification_page] Mime-Type "text/html" Set-Cookie "NotificationDone=[clock seconds]; path=/; domain=.[HTTP::host]"
            }
            pool http_pool  
            }
    }
    

    }