Bug 39806

Summary: Add env vars to mod_proxy_balancer to allow more control
Product: Apache httpd-2 Reporter: Brian <brectanu>
Component: mod_proxy_balancerAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED FIXED    
Severity: enhancement Keywords: PatchAvailable
Priority: P2    
Version: 2.2.2   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: patch
mod_proxy_balancer-trunk.patch
mod_proxy_balancer-trunk.patch

Description Brian 2006-06-13 21:31:42 UTC
Hello,

Here is a very simple patch to add some env vars to mod_proxy_balancer.  This
allows you to figure out where the request was routed from the reverse proxy.  I
needed this to add sticky session cookies to the response because I could not
modify the backend app.

So, you can do something like this on the reverse proxy:

SetEnvIf ^Cookie$ "MYCOOKIE=([^ ;]*)" MYCOOKIE=$1
Header append Set-Cookie "MYCOOKIE=%{UNIQUE_ID}e.%{BALANCER_WORKER_ROUTE}e;
path=/" env=!MYCOOKIE

RewriteRule ^/+(.*) balancer://test/$1 [P]
ProxyPassReverse / balancer://test/

<Proxy balancer://test>
  BalancerMember http://host1 route=host1
  BalancerMember http://host2 route=host2
</Proxy>
ProxySet balancer://test stickysession=MYCOOKIE nofailover=On
Comment 1 Brian 2006-06-13 21:33:19 UTC
Created attachment 18457 [details]
patch

quick patch to add env vars to mod_proxy_balancer
Comment 2 Jeff Trawick 2006-06-14 12:51:21 UTC
Nice tool.

If you want to log this, use %{BALANCER_foo}e in the access log.  I don't see
the need for the debug-level error log messages.  Other opinions from the crowd?
Comment 3 Brian 2006-06-14 19:14:22 UTC
Created attachment 18467 [details]
mod_proxy_balancer-trunk.patch

Cleaned up patch, added patch to docs, against trunk.
Comment 4 Brian 2006-06-14 19:16:43 UTC
Created attachment 18468 [details]
mod_proxy_balancer-trunk.patch

Let's try that again w/o the tab characters ;)
Comment 5 Brian 2006-06-14 19:19:34 UTC
ok, removed the debug stuff (not needed).  I also went against trunk and added a
patch to the docs as well.
Comment 6 Ruediger Pluem 2006-06-26 17:09:06 UTC
Committed to trunk as r417238
(http://svn.apache.org/viewvc?rev=417238&view=rev). Thanks.