You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Douglas WF Acheson <dw...@dwfa.ca> on 2006/02/16 19:47:56 UTC

[users@httpd] Proxying and load balancing

Hello,

  I am trying to set up httpd (v2.2.0) as a load balancer (for development testing, poc stuff) using the mod_proxy_balancer (and appropriate dependencies).  I am fronting a J2EE applications running under tomcat 5.5.15 on two machines.

  I seem to have it working for the most part, but am confused by  a couple of things:

1. The URL in the web browser changes when I access the LB, that is the LB actually does a client side redirect:
For example the URL I use is
  192.168.1.1:8080/myProject
but when the page renders, the URL is now
  192.168.1.2:8080/myProject
or
  192.168.1.3:8080/myProject

What I want to achieve is, have the URL remain in the context of the LB/proxy (or reverse proxy), so that if machine 1 goes away the LB can redirect to another machine.  'Cause right now the user will have to enter the URL of the LB to get to the app if something fails.

2. In the segment below, there is a section "<Location /tc-bal>" that seems to be needed.  I do not understand why?  I crafted this using the examples config files with the install for win32.

  Thx in advance for help ...

Regards,
Douglas WF Acheson

<!-- snip snip -->
<IfModule !proxy_module>
    LoadModule proxy_module modules/mod_proxy.so
</IfModule>

#<IfModule !proxy_ajp_module>
#    LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#</IfModule>

<IfModule !proxy_http_module>
    LoadModule proxy_http_module modules/mod_proxy_http.so
</IfModule>

<IfModule !proxy_balancer_module>
    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
</IfModule>

# ---------------------------------------------------------------------------- #
# Define the tomcat load balancer                                              #
# ---------------------------------------------------------------------------- #

<IfModule proxy_balancer_module>
	ProxyRequests off

  <Proxy balancer://bpsCluster>
      BalancerMember http://192.168.1.1:8080 loadfactor=50
      BalancerMember http://192.168.1.3:8080 loadfactor=50
      Order Deny,Allow
      Allow from all
  </Proxy>

  <Location /tc-bal>
      ProxyPass balancer://myCluster stickysession=jsessionid
  </Location>

  <Location /balancer-manager>
      SetHandler balancer-manager
      Order Deny,Allow
      Allow from all
  </Location>

  <Location /BpsProject>
      ProxyPass balancer://myCluster/myProject
      ProxyPassReverse balancer://myCluster/myProject
      Order Deny,Allow
      Allow from all
  </Location>

</IfModule>

Regards,
Douglas WF Acheson 



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Proxying and load balancing

Posted by Ian Shafer <ia...@1321.org>.
Check out the proxyHost and proxyPort XML attributes on this page:

http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

Basically, you need to set these to your load balancer. Then clients
will always go through the load balancer.

Ian

On  0, Douglas WF Acheson <dw...@dwfa.ca> did scribble:
> Hello,
> 
>   I am trying to set up httpd (v2.2.0) as a load balancer (for development testing, poc stuff) using the mod_proxy_balancer (and appropriate dependencies).  I am fronting a J2EE applications running under tomcat 5.5.15 on two machines.
> 
>   I seem to have it working for the most part, but am confused by  a couple of things:
> 
> 1. The URL in the web browser changes when I access the LB, that is the LB actually does a client side redirect:
> For example the URL I use is
>   192.168.1.1:8080/myProject
> but when the page renders, the URL is now
>   192.168.1.2:8080/myProject
> or
>   192.168.1.3:8080/myProject
> 
> What I want to achieve is, have the URL remain in the context of the LB/proxy (or reverse proxy), so that if machine 1 goes away the LB can redirect to another machine.  'Cause right now the user will have to enter the URL of the LB to get to the app if something fails.
> 
> 2. In the segment below, there is a section "<Location /tc-bal>" that seems to be needed.  I do not understand why?  I crafted this using the examples config files with the install for win32.
> 
>   Thx in advance for help ...
> 
> Regards,
> Douglas WF Acheson
> 
> <!-- snip snip -->
> <IfModule !proxy_module>
>     LoadModule proxy_module modules/mod_proxy.so
> </IfModule>
> 
> #<IfModule !proxy_ajp_module>
> #    LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
> #</IfModule>
> 
> <IfModule !proxy_http_module>
>     LoadModule proxy_http_module modules/mod_proxy_http.so
> </IfModule>
> 
> <IfModule !proxy_balancer_module>
>     LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
> </IfModule>
> 
> # ---------------------------------------------------------------------------- #
> # Define the tomcat load balancer                                              #
> # ---------------------------------------------------------------------------- #
> 
> <IfModule proxy_balancer_module>
> 	ProxyRequests off
> 
>   <Proxy balancer://bpsCluster>
>       BalancerMember http://192.168.1.1:8080 loadfactor=50
>       BalancerMember http://192.168.1.3:8080 loadfactor=50
>       Order Deny,Allow
>       Allow from all
>   </Proxy>
> 
>   <Location /tc-bal>
>       ProxyPass balancer://myCluster stickysession=jsessionid
>   </Location>
> 
>   <Location /balancer-manager>
>       SetHandler balancer-manager
>       Order Deny,Allow
>       Allow from all
>   </Location>
> 
>   <Location /BpsProject>
>       ProxyPass balancer://myCluster/myProject
>       ProxyPassReverse balancer://myCluster/myProject
>       Order Deny,Allow
>       Allow from all
>   </Location>
> 
> </IfModule>
> 
> Regards,
> Douglas WF Acheson 
> 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: Proxying and load balancing

Posted by Joost de Heer <sa...@xs4all.nl>.
>   <Proxy balancer://bpsCluster>
>       BalancerMember http://192.168.1.1:8080 loadfactor=50
>       BalancerMember http://192.168.1.3:8080 loadfactor=50
>   </Proxy>

>   <Location /BpsProject>
>       ProxyPass balancer://myCluster/myProject
>       ProxyPassReverse balancer://myCluster/myProject

What this does is 'replace in the returned headers the text
'balancer://myCluster/myProject'', and that text of course never appears
in the returned headers. It should be:

ProxyPassReverse http://192.168.1.1:8080/myProject
ProxyPassReverse http://192.168.1.3:8080/myProject

May I ask why you don't use ajp proxying by the way? It should be slightly
faster than http proxy.

Joost


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org