Forum Discussion

Hem_66900's avatar
Hem_66900
Icon for Cirrus rankCirrus
Nov 25, 2014

Irule not working to insert header value when we issue URI redirect in different irule as below

Irule not working to insert header value when we issue URI redirect in different irule as below.

 

Rule 1:-irule.x-forwarded-for.fix when HTTP_REQUEST { if {[HTTP::header exists True-Client-IP] } { HTTP::header insert WL-Proxy-Client-IP [HTTP::header value True-Client-IP] } else { HTTP::header insert WL-Proxy-Client-IP [IP::client_addr] }

 

Rule2:- irule.site.maintenance:- when HTTP_REQUEST {

 

Set value to 1 if auto mobile maintenance required. Set value to 0 If there is no auto mobile maintenance required. Default Value is 0.

set mobile_maintenance_prod 1

 

if { $mobile_maintenance_prod==1 } { switch -glob [string tolower [HTTP::path]] { "/abc/*" { set json "{ "Maintainance Message" } HTTP::respond 200 content $json "Content-Type" "application/json"; event disable; unset json; }

 

/Uri1* /Uri2* /ur3* { HTTP::redirect "/auto/site-unavailable/index.html"; event disable; } } } }

 

Note:-Please dont blame for bracing issues.

 

1 Reply

  • header insertion and http redirection should not be triggered on the same request, shouldn't they? you can disable event after either action is executed using event command. event   https://clouddocs.f5.com/api/irules/event.html alternatively, you may do header insertion in HTTP_REQUEST_SEND instead (of HTTP_REQUEST). HTTP_REQUEST_SEND   https://clouddocs.f5.com/api/irules/HTTP_REQUEST_SEND.html