Application Delivery (ADX)

Reply
Contributor
Posts: 20
Registered: ‎02-13-2013

OpenScript example

Hi

I'm looking for OpenScript which will display page that there is temporary problem when all HealthCheck within VIP are not working. Eg. I have VIP with port 80, and two real servers servering HTTP service for this VIP. I would like to display web page that is temp. problem if both HTTP real servers are not working (i.e. health-checks results failed).

 

Michal

 

Brocadian
Posts: 1
Registered: ‎12-15-2011

Re: OpenScript example

add this global config on adx:

 

server l7-dont-reset-on-vip-port-fail

 

refer to below sample script(this is published in community also):

 

 

# Purpose: Check Host Header and based on that respond with redirect messages
# Host with
#   www.host1.com - default redirect
#   www.host2.com - redirect domain
#   www.host3.com - redirect domain, status-code
#   www.host4.com - redirect domain, status-code, url
#   www.host5.com - redirect domain, status-code, url, port
#  If no match, send reset to Client

use OS_SLB;
use OS_HTTP_REQUEST;

#############################################
#
# HTTP REQUEST EVENTS
#
#############################################

sub HTTP_REQUEST {
 
 # Get the URL from the request
 my $client_host = OS_HTTP_REQUEST::host;
 print "\n\nClient Request has this HOST Header - $client_host\n\n";

 # Group selection based on the HOST in the request
 if ($client_host =~ m/www.host1.com$/) {
  print "Matched www.host1.com";
  OS_SLB::redirect;
 } elsif ($client_host =~ m/www.host2.com$/) {
  print "Matched www.host2.com";
  OS_SLB::redirect("domain" => "www.newhost2.com");
 } elsif ($client_host =~ m/www.host3.com$/) {
  print "Matched www.host3.com";
  OS_SLB::redirect("domain" => "www.newhost3.com", "status-code" => "545");
 } elsif ($client_host =~ m/www.host4.com$/) {
  print "Matched www.host4.com";
  OS_SLB::redirect("domain" => "www.newhost4.com", "status-code" => "645", "url" => "/newpage4.html");
 } elsif ($client_host =~ m/www.host5.com$/) {
  print "Matched www.host5.com";
  OS_SLB::redirect("domain" => "www.newhost5.com", "status-code" => "745", "url" => "/newpage5.html", "port" => "8980");
 } else {
  print "Did not match predefined Host. Reply Error to client";
         my $req_vers = OS_HTTP_REQUEST::version;
         my $err_code = "HTTP/$req_vers 500 Server Error\r\nConnection: Close\r\nContent-Length: 23\r\n\r\n Site under Maintenance";
         OS_SLB::reply($err_code);
 }
}

 

sub SERVER_SELECTION_FAILURE {
 print "\n\n*** Selected group Servers not available. Send Error Code 500 to Client***\n\n";
 
 my $req_vers = OS_HTTP_REQUEST::version;
 my $err_code = "HTTP/$req_vers 500 Server Error\r\nConnection: Close\r\nContent-Length: 23\r\n\r\n Site under Maintenance";
 OS_SLB::reply($err_code);

 

 

 

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.

vADC is now Pulse Secure
Download FREE NVMe eBook