vADC Forum

Reply
Occasional Contributor
Posts: 13
Registered: ‎07-30-2013
Accepted Solution

Set header with Generic Streaming Protocol?

Hi All:

I have a Generic Streaming virtual server in order to demultiplex the traffic incoming for an especific port. The question is:

How I can modify the header when the request are http? .I know that I could add a parmeter such as :

http.setHeader("X-Forwarded-For", request.getRemoteIP());

Contributor
Posts: 74
Registered: ‎10-03-2011

Re: Set header with Generic Streaming Protocol?

Hi Felix,

Unfortunately you can't use the HTTP class of functions with non-http protocols. You will need to use request.get()/request.set() instead. Something like this might work...


$line = request.get( request.getLength() );


if ( string.regexmatch($line, "(.*?HTTP/1.*?)\r\n\r\n(.*)") ) {


   request.set($1 . "\r\n" . "X-Forwarded-For: " .


     request.getRemoteIP() . "\r\n\r\n" . $2 );


}



As this is not HTTP, you will see you have an option to run the rule once or every. You will need to set that to every if you want to execute the rule on every request, rather than just on initial connection.


You may also find this blog post useful: Stingray Technical Blog: October 2006


Cheers,

Mark


Occasional Contributor
Posts: 13
Registered: ‎07-30-2013

Re: Set header with Generic Streaming Protocol?

Ok, thanks so much Mark, I will test the script and put the result here.

Regards

Felix

Occasional Contributor
Posts: 13
Registered: ‎07-30-2013

Re: Set header with Generic Streaming Protocol?

Mark:

This script work perfectly but not for all request. The problem is that appear the origin IP in only a few numbers of request.

( string.regexmatch($line, "(.*?HTTP/1.*?)\r\n\r\n(.*)") )  ????


What about set header in non-http connections?.


Regards and thanks so much for the reply.


Felix

Occasional Contributor
Posts: 13
Registered: ‎07-30-2013

Re: Set header with Generic Streaming Protocol?

Hi Mark:

Finally this is the script with a little modification.

$data = request.get()

$count = 500

while( $data == "" && $count-- > 0 )

   connection.sleep( 10 );

   $data = request.get()

}

if ( string.regexmatch($data, "(.*?HTTP/1.*?)\r\n\r\n(.*)") )

   request.set($1 . "\r\n" . "X-Forwarded-For: " .  

    request.getRemoteIP() . "\r\n\r\n" . $2 )

}


Now I can catch all of the origin IP but only fot HTTP and HTTPS (with SSL Offload).

Thanks so much for your reply and for the script.


Cheers


Felix

Join the Community

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