Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

how to display maintenance banner via LTM policy

Bhupendra
Altocumulus
Altocumulus

how to display maintenance banner via LTM policy if uri matches /example and tcp address is not private_net

Note: banner file (HTML ) is stored on ifile list.

7 REPLIES 7

M_Saeed
Cirrus
Cirrus

Hi @Bhupendra 
Hope you are doing well.

You coudl do it via iRule redirection to a sorry page OR you could provide it directly after matching your conditions as requested above.

SOL1#
--------------------------------------

when HTTP_REQUEST {

#create a data group adding allowed_ip_addresses to assign it here in iRule

if { ([HTTP::uri] starts_with "/example") && (![class match [IP::client_addr] equals allowed_ip_addresses]) } {

HTTP::redirect "http://www.corp_xyz.com/sorry_page.html

log local0. "Client IP : [IP::client_addr] ==> sorrypage"

}
}

 

SOL#2
-----------------------

when HTTP_REQUEST {

#make sure to create a data group adding allowed_ip_addresses to assign it here in iRule

if { ([HTTP::uri] starts_with "/example") && (![class match [IP::client_addr] equals allowed_ip_addresses]) } {

HTTP::respond 200 content {
<html>
<head>
<title>Apology Page</title>
</head>
<body>
We are sorry, but the site you are looking for is temporarily out of service<br>
If you feel you have reached this page in error, please try again.
</body>
</html>
}
}
}

 

Hi , Thanks for your response.

I have both  irule and LTM policy on same vip. 

LTM policy rule -------->

HTTP URI full string starts with '/example' at request time.

Forward traffic to POOL A

---------------------------------------------------------------------------------

Banner rule----->

when HTTP_REQUEST {

if { ([HTTP::uri] starts_with "/example") 

HTTP::respond 200 content {
<html>
<head>
<title>Apology Page</title>
</head>
<body>
We are sorry, but the site you are looking for is temporarily out of service<br>
If you feel you have reached this page in error, please try again.
</body>
</html>
}
}
}

 I tried to put simple messgae on banner. It is not working. Always says site can not be reached.  connection reset message .I can see execution hits on irule without error. Also LTM logs i can see irule executed.

 

 

whisperer
Nacreous
Nacreous

Just to clarify, you are looking for a maintenance page? When you say 'banner', it makes me think that you want to inject javascript or somerthing and put a banner atop the normally loaded page that provides an alert. That would be a separate and more difficult requirement of course. Simple maintenace page is no issues, and you can even store the HTML page, JS, and any images on the F5 itself using iFiles. Just some further thoughts here.

Hi Whisperer,

Thanks for response.

I am putting maintenance page. I tried to put simple html page or message. Also tried to put html page via ifile (HTTP::respond 200 content [ifile get "maintenance_Page"] even it is not working for me.

 

when HTTP_REQUEST {

if { ([HTTP::uri] starts_with "/example") 

HTTP::respond 200 content {
<html>
<head>
<title>Apology Page</title>
</head>
<body>
We are sorry, but the site you are looking for is temporarily out of service<br>
If you feel you have reached this page in error, please try again.
</body>
</html>
}
}
}

Can you provide the output for the Virtual Server object? Also, what URL are you testing with in the web browser?

Hi ,

I found the issue. There are two irule applied on VIP. First irule mainentance page  and second irule to set same site cookie as none .

In Packet capture i saw irule exceution error. First irule for mainentance page when http request is matching and it is responding to 200 with maintenece page.

when second irule is exceuting, it is the http response release  to set  same site cookie as none as  first irule is already executed with response. It is failing.

For testing i have removed second irule(same site cookie), it is working.

Just want to know if  below same site irule is feasible via LTM policy or other solution.

same site irule-

when HTTP_RESPONSE_RELEASE {
set cookie_names [HTTP::cookie names]
foreach a_cookie $cookie_names
{
if {not [HTTP::cookie attribute $a_cookie exists {SameSite}] }
{HTTP::cookie attribute $a_cookie insert "SameSite" "None"}
}
}

 

 

Regarding LTM policies, They may not have the same level of granularity in event triggers as iRules, which can be triggered at various stages of traffic processing. You may need to stick with iRule in your case.