From 58f86ac058df0d413054cfef286a3824017737cf Mon Sep 17 00:00:00 2001 From: Ruediger Pluem Date: Mon, 26 Jun 2006 16:59:38 +0000 Subject: [PATCH] * 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 --- CHANGES | 4 +++ docs/manual/mod/mod_proxy_balancer.xml | 41 ++++++++++++++++++++++++++ modules/proxy/mod_proxy_balancer.c | 14 +++++++++ 3 files changed, 59 insertions(+) diff --git a/CHANGES b/CHANGES index c35fe48fb5..21f7ea1528 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 1fa7360736..c0cb40d072 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 de1a15a476..e76dd1cfbc 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", -- 2.40.0