Forum Discussion
Help with IRule
Can you please help with the following iRule which is not working at all.
For client IPs that do NOT match SS_CMS_Nets and hit the URI specified in SS_CMS_URLs redirect back to /
when HTTP_REQUEST {
if { not ([matchclass [IP::client_addr] equals $::SS_CMS_Nets]) and ([string tolower [HTTP::uri]] contains $::SS_CMS_URLs) } {
HTTP::redirect "/"
}
}
SS_CMS_Nets
192.168.1.0/255.255.255.0
SS_CMS_URLs
"/server2"
Many thanks,
esexon
- Richard__HarlanHistoric F5 AccountWhat version are you running? Is there any error in the \var\log\ltm? The iRule looks valid on version 9.x it will cause the VIP to bind to TMM0 is on a newer platform. If you are running 10 or above you need o rewrite the iRule using the class command.
- esexon_28265NimbostratusThanks,
- esexon_28265NimbostratusHi sorry,
- Brian_69413NimbostratusI have always assumed the redirect needed an absolute path, so:
HTTP::redirect "http://[HTTP::host]/"
- esexon_27963Nimbostratus
Many thanks for the reply. I have tried the absolute URL but this does not make any difference.
- Brian_69413NimbostratusOops, I see it now, try this line instead:
when HTTP_REQUEST { if { not ([matchclass [IP::client_addr] equals $::SS_CMS_Nets]) and ([matchclass [string tolower [HTTP::uri]] contains $::SS_CMS_URLs]) } { HTTP::redirect "/" } }
- esexon_27963NimbostratusThanks very much. This has worked perfectly.
- JCohenRet. EmployeeTo be 10.x friendly and not demote your Virtual from CMP use this instead.
- JCohenRet. EmployeeOK... can't edit my post and put the code formatting around it, so sorry for the repost.
when HTTP_REQUEST { if {not {[class match [IP::client_addr] equals SS_CMS_Nets]) and ([class [string tolower [HTTP::uri]] contains SS_CMS_URLs]) } { HTTP::redirect "/" } }
- hooleylistCirrostratusFixed a couple of minor typos:
when HTTP_REQUEST { if {not ([class match [IP::client_addr] equals SS_CMS_Nets]) and ([class match [string tolower [HTTP::uri]] contains SS_CMS_URLs]) } { HTTP::redirect "/" } }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com