Blogs Blogs

Running Proxy Sniffer as a reverse proxy in order to capture HTTP traffic

 

In some situations there is the need to record the HTTP traffic occurring between two machines in order to run a loadtest against the target machine.

In such situations Proxy Sniffer can be configured to act as a reverse proxy. Assuming that we want to capture the traffic generated by machine A with target machine B, we'll configure a Proxy Sniffer instance (machine C) to accept traffic on behalf of machine B and then forwad all HTTP requests on to B.

In praxis the following needs to be done:

  • Run Proxy Sniifer to act as a reverse proxy by creating a custom startup script similar as follows:
java -Xmx1024m -Xbootclasspath/p:./prxsniff.jar ProxySniffer -WebAdmin -tz EST  -httpPort <target_port> -httpWebServer <server-dns-name>:<server-ip-addresse>:<server-ip-port>

These arguments will need to be adapted:

-httpPort: the port PS will listen on for incoming request (... to be reverse-proxied)
-httpWebServer: <server-dns-name>:<server-ip-addresse>:<server-ip-port>   (.. these are the coordinates of the target HTTP server...)
 
  • Add an entry to the hosts files of machine A so that B's FQDN resolves to Proxy Sniffer's (machine C) IP address. Generally on a Unix system you'd modify the /etc/hosts file. On Windows the relevant file to ne modified would be \windows\system32\drivers\etc\hosts .

Then start a Proxy Sniffer recording session as usual. You'll then be able to use the recorded session as a basis to build a load test script.

As of this writing it is not possible to use Proxy Sniffer as a reverse proxy if the endpoint (machine C) only accepts encrypted traffic (SSL).

Scripting Proxy Sniffer load tests

 

Sometimes there is the need to run the same loadtest simulating different load levels (virtual users) or you'd simply run the test at regular intervals or at odd times.

Should that be the case you can create a script that can invoke Proxy Sniffer and run the required load tests for. Below you'll find an example of a bash script that can be used on any Unix derivative, including OS X.

 

#!/bin/bash

 

##############################################

#

#

# Sample Proxy Sniffer script showing how a test can be run

# at different virtual users levels without manual intervention

# on a PS cluster.

# Copy this script in the PS home foldwr (where prxsniff.jar is located)

# and then adapt the various parameters below (... see comments)

###############################################

 

CLASSPATH=prxsniff.jar

JAVA='/usr/bin/java'

export CLASSPATH

 

# Path to the test class or zip file you want to have executed

TESTNAME=MyTests/aa_auth.zip

# The prefix to be used for the results filenames (.prxres files)

PREFIX=aa_auth_23Apr_001_

# Cluster to run the test on

CLUSTER=Test

# URL request timeout, in seconds

TIMEOUT=60

#How long each test run will last, in seconds

DURATION=300

#Startup-delay for each virtual user, in milliseconds

SDELAY=100

#Maximum number of loops for each virtual user

MAXLOOPS=0

#Optional: Other test-specific parameters (required by plugins, etc...)

PARGS="-aaport 8080 -aaip 10.32.27.115"

 

#Specify on the next line the number of virtual users that each

#test execution should run at

for i in 10 20 40 80 100 150 200

 

do

 

        echo Executing test with $i users...

        $JAVA java  -Xbootclasspath/p:./prxsniff.jar PrxJob transmitClusterJob $CLUSTER $TESTNAME -u $i -d $DURATION -t $TIMEOUT -sdelay $SDELAY -maxloops $MAXLOOPS $PARGS

        JOBID=$?

        echo Running cluster job $JOBID

        sleep 5

        java  -Xbootclasspath/p:./prxsniff.jar PrxJob startClusterJob $CLUSTER $JOBID

#       echo $?

        java  -Xbootclasspath/p:./prxsniff.jar PrxJob waitForClusterJobCompletion  $CLUSTER $JOBID

#       echo $?

        echo Collecting results... 

        java  -Xbootclasspath/p:./prxsniff.jar PrxJob acquireClusterJobResultFile $CLUSTER $JOBID $PREFIX$i.prxres

 

done

"Undefined symbol .sqrt " while compiling Apache 2.x on AIX 5.2

 

While compiling Apache 2.x on AIX 5.2, the compilation process aborted with the following error message

ld: 0711-317 ERROR: Undefined symbol: .sqrt 
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. 
collect2: ld returned 8 exit status 
make: 1254-004 The error code from the last command is 1.


The sqrt function is implement in the libm math library, which is needed when linking Apache.

You can verify whether libm is installed on your system by running: 

# lslpp -l | grep bos.adt.libm 
bos.adt.libm              5.2.0.50  COMMITTED  Base Application Development


If bos.adt.libm is not installed, please copy bos.adt from AIX installation disk 1 to your system and  install it as follows: 
  

installp -aXYgd . bos.adt


Re-run Apache's configure script and then restart the compilation process. This time the error mentioned above shouldn' t occur.

Using Proxy Sniffer as a monitoring tool

 

Some Proxy Sniffer users indicated that they're using several Exec Agents in order to execute ligthweight load tests at regular intervals. Sounds like a good idea to make your Proxy Sniffer investment go further.

Load tests can be easily scheduled and run via Proxy Sniffer's scripting language. Results can then also automatically be consolidated back into one controlling Proxy Sniffer instance.

In an upcoming Proxy Sniffer release we'll be adding alarming features, so that an email is released when some conditions are met. 

Showing 4 results.