Script example, Overview, Use case – Brocade Virtual ADX OpenScript Programmer’s Guide (Supporting ADX v03.1.00) User Manual
Page 29: Script for use case, Chapter 4, Chapter

Brocade Virtual ADX OpenScript Programmer’s Guide
21
53-1003244-01
Chapter
4
Script Example
Overview
The following sections of this chapter describe the entire process of writing a script, copying it to
the Brocade Virtual ADX and binding it to a virtual server port
Use case
This script is created in this example is designed to perform the following action on any HTTP
traffic:
•
If there is no X-Forwarded-For header, an X-forwarded-For header is added with the client
source IP address: e.g. 4.4.4.4
•
If a X-Forwarded-For header exists, the source IP address 4.4.4.4 is appended. For example,
existing X-forwarded-For address: 1.1.1.1, 2.2.2.2, 3.3.3.3 + appended source address:
4.4.4.4, results in new source address: 1.1.1.1, 2.2.2.2, 3.3.3.3, 4.4.4.4.
Script for use case
The following script implements the example described in
. For additional sample
scripts, search with
Example 1:
use OS_HTTP_REQUEST;
use OS_IP;
use OS_SLB;
my $group1 = "";
BEGIN {
$group1 = 10;
}
sub HTTP_REQUEST{
$x_forward = OS_HTTP_REQUEST::header("X-Forwarded-For");
$src_addr = OS_IP::src;
if( defined $x_forward){
$x_forward = $x_forward.", ".$src_addr;
OS_HTTP_REQUEST::header("X-Forwarded-For", $x_forward);
}else{
OS_HTTP_REQUEST::push_header("X-Forwarded-For", $src_addr);
}
OS_SLB::forward($group1);
}