From: Ruediger Pluem Date: Mon, 26 Jun 2006 16:59:38 +0000 (+0000) Subject: * Add the following environment variables to expose the information X-Git-Tag: 2.3.0~2310 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58f86ac058df0d413054cfef286a3824017737cf;p=thirdparty%2Fapache%2Fhttpd.git * Add the following environment variables to expose the information * about the route, the sticky session and the worker used during a request to other modules: BALANCER_SESSION_STICKY BALANCER_SESSION_ROUTE BALANCER_NAME BALANCER_WORKER_NAME BALANCER_WORKER_ROUTE PR: 39806 Submitted by: Brian Reviewed by: rpluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@417238 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index c35fe48fb59..21f7ea15283 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,10 @@ Changes with Apache 2.3.0 [Remove entries to the current 2.0 and 2.2 section below, when backported] + *) mod_proxy_balancer: Add information about the route, the sticky session + and the worker used during a request as environment variables. PR 39806. + [Brian ] + *) mod_isapi: Avoid double trailing slashes in HSE_REQ_MAP_URL_TO_PATH support. Also corrects the slashes for Windows. PR 15993 [William Rowe] diff --git a/docs/manual/mod/mod_proxy_balancer.xml b/docs/manual/mod/mod_proxy_balancer.xml index 1fa73607369..c0cb40d072e 100644 --- a/docs/manual/mod/mod_proxy_balancer.xml +++ b/docs/manual/mod/mod_proxy_balancer.xml @@ -271,6 +271,47 @@ candidate lbstatus -= total factor +
+ Exported Environment Variables +

At present there are 5 environment variables exported:

+ + +
BALANCER_SESSION_STICKY
+
+

This is assigned the stickysession value used in the current + request. It is the cookie or parameter name used for sticky sessions

+
+ + +
BALANCER_SESSION_ROUTE
+
+

This is assigned the route parsed from the current + request.

+
+ + +
BALANCER_NAME
+
+

This is assigned the name of the balancer used for the current + request. The value is something like balancer://foo.

+
+ + +
BALANCER_WORKER_NAME
+
+

This is assigned the name of the worker used for the current request. + The value is something like http://hostA:1234.

+
+ + +
BALANCER_WORKER_ROUTE
+
+

This is assigned the route of the worker that will be + used for the current request.

+
+ +
+
Enabling Balancer Manager Support

This module requires the service of diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index de1a15a476c..e76dd1cfbcb 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -389,6 +389,14 @@ static int proxy_balancer_pre_request(proxy_worker **worker, *worker = runtime; } + /* Add balancer/worker info to env. */ + apr_table_setn(r->subprocess_env, + "BALANCER_NAME", (*balancer)->name); + apr_table_setn(r->subprocess_env, + "BALANCER_WORKER_NAME", (*worker)->name); + apr_table_setn(r->subprocess_env, + "BALANCER_WORKER_ROUTE", (*worker)->s->route); + /* Rewrite the url from 'balancer://url' * to the 'worker_scheme://worker_hostname[:worker_port]/url' * This replaces the balancers fictional name with the @@ -399,6 +407,12 @@ static int proxy_balancer_pre_request(proxy_worker **worker, if (route) { apr_table_setn(r->notes, "session-sticky", (*balancer)->sticky); apr_table_setn(r->notes, "session-route", route); + + /* Add session info to env. */ + apr_table_setn(r->subprocess_env, + "BALANCER_SESSION_STICKY", (*balancer)->sticky); + apr_table_setn(r->subprocess_env, + "BALANCER_SESSION_ROUTE", route); } ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy: BALANCER (%s) worker (%s) rewritten to %s",