Application Layer Switching Module for Apache
1.1. Request Processing Cycle
1.2. Event Functions
2.2.9. set_header($hdrName, $hdrValue)
2.2.10. add_header($hdrName, $hdrValue)
2.3.2. add_header($hdrName, $hdrValue)
2.3.4. send_redirect($url[, $status])
3.1. Example 1 - Select Pool
3.1.1. Apache Configuration
3.1.2. Control Script
3.2. Example 2 - Request rewriting
3.2.1. Apache Configuration
3.2.2. Control Script
Control scripts can be used for performing powerful traffic manipulation operations and advanced load balancing decisions. Control scripts are normal Perl sub-routines which are called at different phases of request processing cycle.
TODO: image of request processing cycle...
|ON_STARTUP||Triggered when server is starting up or after configurations are re-loaded|
|ON_SHUTDOWN||Triggered when server is shutting down or before configurations are re-loaded|
|ON_REQUEST||Triggered when HTTP request line and headers are received and processed before they are sent to server pool|
|ON_REQUEST_DATA||Triggered when HTTP request body is being sent to server (may be triggered 0...N times)|
|ON_RESPONSE||Triggered when HTTP response status line and headers are received and processed before they are sent to client|
|ON_RESPONSE_DATA||Triggered when HTTP response body is being sent to the client (may be triggered 0...N times)|
|ON_LBFAILURE||Triggered when selected pool member was unavailable, it is possible to send HTTP redirect or attempt to connect to other pool.|
Please use convienence routine L7::Runtime::OBJECTS(@_) to obtain handles to event functions objects. This method hides the Perl XS method call parameters from event functions. This is subject to change in future releases; propably event function specific methods like L7::Runtime::ON_REQUEST(@_), L7::Runtime::ON_RESPONSE(@_), ...
L7::Runtime object re-presents mod_layer runtime and provides access to configured items such as pools and pool members...
Select L7Pool for processing current request.
Select specific pool member identified by $url.
Get number of configured pool members for pool $poolName.
Get number of available pool members for pool $poolName.
L7::HTTPRequest object re-presents current HTTP request and provides access to common request properties such as URI and request headers. It is also possible to manipulate request properties within ON_REQUEST event function. Attempt to manipulate request properties in other event functions may fail silently, cause module to crash or simply have no actual effect.
Get client IP address as string.
Get client TCP port number as integer value.
Get HTTP request URI for current request.
Set HTTP request URI to value $uri. This can be used for request URI rewriting in ON_REQUEST event function before request is directed to L7Pool for processing.
Get current query string.
Set query string before request is passed to L7Pool for processing.This method should be used only in ON_REQUEST event function
Get current HTTP request method name (eg. "GET", "POST", ..).
Get HTTP request header $hdrName from current request properties.
Set HTTP request header $hdrName to value $hdrValue.
Add HTTP request header $hdrName with value $hdrValue.
Remove HTTP request header with name $hdrName.
Get HTTP response header $hdrName.
Add HTTP response header $hdrName with value $hdrValue.
Remove HTTP response header $hdrName before response is sent to client.
Send HTTP redirect to location specified by $url. It is possible to specify HTTP status code used for redirect by giving optional $status parameter (default: 303).
Specify whether caching may or may not be used. Caching functionality is provided by mod_cache.
This example shows how control script can be used for selecting to which L7Pool current request is directed.
Use L7::Runtime::OBJECTS(@_) to obtain handles to event functions objects.
This example shows hot to perform simple request rewriting ...