• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Apache loadbalancing, mod_rewrite, mod_proxy

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 3 tomcat servers running on different machines and Apache server running on another machine. I want to make Apache
reverseproxing and loadbalancing this backend servers.
What I have done:
=================
1. In Apache's httpd.conf:
<VirtualHost _default_:80>
ServerName www.myserver.com
RewriteEngine on
RewriteMap server rnd:/rewrite/rproxy.conf
RewriteRule ^/(.*)$ to://${server:web|tomcat_1:8080}/somecontext
RewriteRule ^to://([^/]+)/(.*) http://$1/$2 [P,L]
RewriteRule .* - [F]
#ProxyRequests On
#ProxyPassReverse / http://myserver:8080/somecontext/
#ProxyPassReverse / http://otherserver:8080/somecontext/
#ProxyPassReverse / http://someotherserver:8080/somecontext/
</VirtualHost>
2. In rproxy.conf
www myserver:8080|otherserver:8080|someotherserver:8080
What I want:
==============
1. When type in www.myserver.com to be dispatched to one of the the backend servers.
The above mention code works fine. When I type www.myserver.com I received
http://myserver:8080/somecontext or
http://otherserver:8080/somecontext or
http://someotherserver:8080/somecontext
2.The real backend server hostname to be masked to www.myserver.com.
Unfortunately I can not achive this. If uncomment the ProxyPassReverse directives Apache enters recursion.
http://www.myserver.com - > gets rewrited to http://myserver:8080/jmx-console which is ProxyPassed to http://www.myserver.com
.. and so on..

Issues:
============
What will happen if eventually I succeed with Rewriting, then sessions will be lost.
Can someone help me with this problems?
Thanks in advance
 
Deyan Sultov
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. I find solution for rewriting:
in httpd.conf
<VirtualHost _default_:80>
RewriteEngine on
RewriteLog logs/proxy_rewrite.log
RewriteLogLevel 9
RewriteMap server rnd:rproxy.conf
RewriteRule^(http|https)://.*-[F]
RewriteRule^/(.*)$to://${server:web}/$1
RewriteRule^to://([^/]+)/(.*) http:// $1/$2[P,L]
RewriteRule.*-[F]
ProxyRequestsOn
ProxyPassReverse / http://server_1:8080/
ProxyPassReverse / http://server2:8080/
</VirtualHost>
where rproxy.conf contains:
www server_1:8080|server_2:8080
but still I can not find the solutions with sessions. Each time mod_rewrite + rnd dispatches to a new server where no session received by previos login exist.Anyone can help?
Is it possible at all loadbalancing of servlet/jsp site to be done with Apache + mod_proxy + mod_rewrite?
[ July 10, 2003: Message edited by: Deyan Sultov ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic