Forum Discussion

Scouse_142981's avatar
Scouse_142981
Icon for Nimbostratus rankNimbostratus
Nov 08, 2017

Advise and help is needed, Irule & ifile

Hi Everyone,

 

I am quite new to iRules and iFiles, so i am looking for some help and guidance here.

 

Basically there is a requirement from the Application team whereby they are asking my help to load a maintenance page whenever the below condition is met.

 

Scenario:

 

if user key in "abc.com/w2wHome" then they will get thru and go to the application. if user type in anything besides the above, they will be taken to the maintenance page. The ifile is in html format and i've imported it in to the LTM.

 

Somehow it just doesnt work. Need help, please..

 

My syntax as below:

 

when HTTP_REQUEST { if { [HTTP::host] contains "abc.com"} { if { not [HTTP::uri] contains "w2wHome"} { HTTP::respond 200 content [ifile get maintenance.html] "Content-Type” ”text/html" } } }

 

  • Your logic looks ok, but try specifying the full path for the iFile e.g. "

    /Common/maintenance.html"

     

  • Hello,

    Please follow below steps.

    Import the iFile navigating to System ›› File Management : iFile List ›› import. Add the imported ifile to LTM Local Traffic ›› iRules : iFile List >> create. Attach below irule (Make sure you have renamed the ifile name accordingly.

    when HTTP_REQUEST { 
        if { ([string tolower [HTTP::host]] equals "abc.com") and (![string tolower [HTTP::uri]] equals "w2whome") } {
        HTTP::respond 200 content [ifile get maintenance.html] "Content-Type" "text/html"
        }
    }
    

    Please test it and let me know.

    -Jinshu