Net tools - proxy servers

Description:

Jetty is a powerful embedded web container / web server. Among many other features it has support for proxies. This is some small proxy utilities based on Jettys proxy capability. Note that it is less than a hundred lines of mine on top of Jetty per proxy, so my contribution is pretty small.

Proxies:

NullProxy
proxy that just proxies without doing anything special
LimitingProxy
proxy that limit number of concurrent requests
SlowProxy
proxy that provides an artificial delay in response
HeaderProxy
proxy that injects headers into request
LogProxy
LogProxy that logs requests and responses

Installation:

System requirements:

Java 5 or newer.

Installation Windows:

cd <location>
unzip proxy-bin
unzip win

Installation VMS:

set def <location>
unzip proxy-bin
set file/attr=rfm:stmlf *.jar
unzip -aa vms

Run:

Run Windows:

<location>null ...

or:

<location>limit ...

or:

<location>slow ...

or:

<location>header ...

or:

<location>log ...

Run VMS:

@<location>null ...

or:

@<location>limit ...

or:

@<location>slow ...

or:

@<location>header ...

or:

@<location>log ...

Usage:

NullProxy:

Standard transperent proxy. This can be useful for network/port reasons.

Command:

null listenport forwardurl_prefix

Arguments:

listenport
the local port the proxy will listen on
forwardurl_prefix
prefix for URL that will be requested

Example:

null 10080 http://localhost:80

This proxy will:

LimitingProxy:

Limit number of concurrent requests for some resources. This can be useful to protect the server from being overwhelmed by requests.

Command:

limit listenport forwardurl_prefix targetpath_prefix concurrencylimit busyurl verbose

Arguments:

listenport
the local port the proxy will listen on
forwardurl_prefix
prefix for URL that will be requested
targetpath_prefix
path prefix of what will be limited (use / for all)
concurrencylimit
max. concurrent requests
busyurl
URL requested in case concurrencylimit exceeded
verbose
verbosity: 0 => no output, 1 => output requests resulting in busy, 2 => output all request

Example:

limit 10080 http://localhost:80 /script 10 http://localhost/busy.html 1

This proxy will:

SlowProxy:

Slow down response to some resources. This can be useful to simulate slow network.

Command:

slow listenport forwardurl_prefix targetpath_prefix delay

Arguments:

listenport
the local port the proxy will listen on
forwardurl_prefix
prefix for URL that will be requested
targetpath_prefix
path prefix of what will be slowed down (use / for all)
delay
slow down delay in milliseconds

Example:

slow 10080 http://localhost:80 /foo 500

This proxy will:

HeaderProxy:

Modify headers in request. This can be useful to insert something the server requires.

Command:

header listenport forwardurl_prefix targetpath_prefix hdr1 hdrval1 ... hdrn hdrvaln

Arguments:

listenport
the local port the proxy will listen on
forwardurl_prefix
prefix for URL that will be requested
targetpath_prefix
path prefix of what will be modified (use / for all)
hdr1
header #1 to modify/add
hdrval1
header #1 value
...
...
...
...
hdrn
header #n to modify/add
hdrvaln
header #n value

Example:

header 10080 http://localhost:80 /bar User-Agent "None of your business" X-Dummy Nothing

This proxy will:

LogProxy:

Logs requests and responses for some resources. This can be useful for troubleshooting.

Note that it just logs headers and byte count for body - not full body (that would be problematic for some types of content).

Command:

log listenport forwardurl_prefix targetpath_prefix logfile

Arguments:

listenport
the local port the proxy will listen on
forwardurl_prefix
prefix for URL that will be requested
targetpath_prefix
path prefix of what will be logged (use / for all)
logfile
file with log output

Important: requests will be serialized to avoid messing up log output - this will impact performance.

Example:

log 10080 http://localhost:80 /foobar foobar.log

This proxy will:

License:

Both my code and the Jetty code are available under Apache 2.0 license.