logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Help with Reverse Poxy rewrite rules
Author
amasuriel



Joined: 21 Oct 2010
Posts: 1

PostPosted: Thu 21 Oct '10 17:02    Post subject: Help with Reverse Poxy rewrite rules Reply with quote

Hi. I'm having some real issues with configuring apache to do what I want it to do; I'm pretty novice when it comes to configuration.

Okay, so what I am basically trying to do is host instances of an application for separate clients behind a single domain name.

Say I have domain name mydomain.com. I have an application that runs on Tomcat with the root context of /myapp. I have 2 of these running, one on tomcat1, one on tomcat2.

What I want to do is type something like http://mydomain.com/client1/myapp, which will redirect to the appropriate Tomcat server as http://tomcat1/myapp.

After the session is established, I will use a unique JVM route (like is used for load balancing Tomcat through apache) so that http://mydomain.com/myapp requests for the rest of the session will get rewritten to http://tomcat1/myapp.

I can't get this working.

Here is my current attempt. Any help would be much appreciated.

Code:

<VirtualHost *:80>   
   ServerName mydomain.com
   ServerAlias mydomain.com
   RewriteEngine on
   ProxyRequests off
   ProxyStatus Full
   ProxyPreserveHost On
   
   <Location /server-status>
      SetHandler server-status
   </Location>
 
   RewriteLog "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\client1_rewrite.log"
   RewriteLogLevel 9
   
   #ProxyPassReverse /client1/ http://tomcat1:80/
   #ProxyPassReverse /client1/ http://mydomain.com/
   #ProxyPassReverse /client2/ http://tomcat2:80/   
   
   #RewriteCond %{HTTP_HOST} ^tomcat1$
   #RewriteRule ^(.*)$ http://mydomain.com/$1 [N]
        
   #RewriteRule ^/client1/(.{0}) http://tomcat1:80/myapp [P]
   #RewriteRule ^/client1(.{0}) http://tomcat1:80/myapp [P]
   #RewriteRule ^/client1(.*)$ http://tomcat1:80$1 [P]
   #RewriteRule ^/client1/(.{0})$ http://mydomain.com/client1/myapp [N]
   #RewriteRule ^/client1(.{0})$ http://mydomain.com/client1/myapp [N]
   RewriteCond %{HTTP_REFERER} (/client1/) [OR]
   RewriteCond %{HTTP_COOKIE}   (.client12)    
   RewriteRule ^/(.*)$ client1/$1 [P]
   #RewriteRule ^/(.*)$ http://tomcat1:80/$1 [P]

   
   #RewriteRule ^/client2(.{0}) http://tomcat2:80/myapp [P]
   #RewriteRule ^/client2/(.{0}) http://tomcat2:80/myapp [P]
   #RewriteRule ^/client2(.*)$ http://tomcat2:80$1 [P]
   RewriteCond %{HTTP_REFERER} (/client2/) [OR]
   RewriteCond %{HTTP_COOKIE}   (.client2)
   RewriteRule ^/(.*)$ http://tomcat2:80/$1 [P]   
      
   <location /client1 >
      ProxyPass http://tomcat1:80/
      ProxyPassReverse http://tomcat1:80/   
   </location>
   

   <location /client2/ >
      ProxyPassReverse http://tomcat2:80/   
   </location>   
     
</VirtualHost>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Fri 05 Nov '10 20:26    Post subject: Reply with quote

Please read http://www.apachelounge.com/viewtopic.php?t=3724 and http://www.apachelounge.com/viewtopic.php?t=178

If you still have a question, please ask again!
Back to top


Reply to topic   Topic: Help with Reverse Poxy rewrite rules View previous topic :: View next topic
Post new topic   Forum Index -> Apache