LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-30-2013, 10:40 AM   #1
floss
LQ Newbie
 
Registered: Oct 2006
Location: INDIA
Distribution: Redhat, suse
Posts: 9

Rep: Reputation: 0
apache : Obtain part of url in proxy balancer from one balancer member


I have cluster setup of Apache server . Behind this I have 2 Jboss instances which is load balanced by apache.

The configuration look somewhat like the below

<VirtualHost *:1111>
ServerAdmin admin@example.com
ServerName www.example.com

DocumentRoot "/apps"
ErrorLog "logs/https.www.example.com.-error_log"
TransferLog "logs/https.www.example.com-access_log"
LogLevel warn


<Directory "/apps">
Options -Indexes +FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>


SSLProxyEngine On
SSLProxyVerify On


SSLProxyMachineCertificateFile "/apps/apache/conf/ssl/int/proxy.pem"
SSLProxyCACertificateFile "/apps/apache/conf/ssl/int/cert.pem"


RewriteEngine On

Header set Cache-Control "max-age=60, public"

<Proxy balancer://2node-aa>

BalancerMember https://app01:8089 route=node1
BalancerMember https://app02:8089 route=node2

ProxyPreserveHost On

ProxyPass /aa balancer://2node/aa stickysession=JSESSIONID|jsessionid
ProxyPass /static balancer://2node/static stickysession=JSESSIONID|jsessionid

ProxyPassReverse /aa balancer://2node/aa
ProxyPassReverse /static balancer://2node/static



ProxyPass /1/aa https://app01:8089/aa
ProxyPass /2/aa https://app02:8089/aa

ProxyPassReverse /1/aa https://app01:8089/aa
ProxyPassReverse /2/aa https://app02:8089/aa

ProxyPass /bb balancer://2node/rest stickysession=JSESSIONID|jsessionid
ProxyPassReverse /bb balancer://2node/bb

</VirtualHost>


In the url access certain part of the url i want it to be routed from second node i.e node2 of jboss.

e.g. if i am accessing http://www.example.com/aa/login/login.jsp i need this request to be process by node2 app02 only.

Rest of the request should load balance as normal access. How do i set the apache to do it ?

I have tried lot of rewrite,<Location> and ProxyPassMatch none has worked so far.

Please Help. Thanks in advance.

Last edited by floss; 11-12-2013 at 10:15 AM.
 
Old 10-30-2013, 10:56 AM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
You need to separate the nodes into different balancers. e.g. here's my apache config for balancing reads and writes across servers.

Code:
  # Load balancing to different nodes based on type of requests
  # Send POST, PUT, and DELETEs to writeBalancer
  RewriteCond %{REQUEST_METHOD} ^(POST|PUT|DELETE)$
  RewriteRule ^/(.*)$ balancer://writeBalancer$1 [P]
  # Send GET, HEAD, and OPTIONS to readBalancer
  RewriteCond %{REQUEST_METHOD} ^(GET|HEAD|OPTIONS)$
  RewriteRule ^/(.*)$ balancer://readBalancer$1 [P]
You can add the same BalancerMember to multiple balancers. See the rewrite flags for a description of [P].

SAM

Last edited by sag47; 10-30-2013 at 11:01 AM.
 
Old 10-30-2013, 05:12 PM   #3
floss
LQ Newbie
 
Registered: Oct 2006
Location: INDIA
Distribution: Redhat, suse
Posts: 9

Original Poster
Rep: Reputation: 0
Hi SAM,

Thanks for your reply.

I did try this but it does not work.


<Proxy balancer://2node-aa>

BalancerMember https://app02:8080 route=node2

</Proxy>
RewriteRule ^/aa/login/(.*)$ balancer://2node-aa$1 [P]

I had put it just above the balancer with two node.
Don't see any error in the log file.

Last edited by floss; 11-12-2013 at 10:21 AM.
 
Old 12-01-2013, 10:21 AM   #4
floss
LQ Newbie
 
Registered: Oct 2006
Location: INDIA
Distribution: Redhat, suse
Posts: 9

Original Poster
Rep: Reputation: 0
I used the below statement in the configuration file which resolved the issue.

<Proxy balancer://2node-aa>

BalancerMember https://app02:8080 route=node2

</Proxy>

RewriteRule ^/aa/login/(.*)$ balancer://2node-aa%{REQUEST_URI} [P,QSA,L]

This link help me.

http://stackoverflow.com/questions/1...url-redirectio

-Thanks
 
Old 12-01-2013, 03:30 PM   #5
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Quote:
Originally Posted by floss View Post
Hi SAM,

Thanks for your reply.

I did try this but it does not work.


<Proxy balancer://2node-aa>

BalancerMember https://app02:8080 route=node2

</Proxy>
RewriteRule ^/aa/login/(.*)$ balancer://2node-aa$1 [P]

I had put it just above the balancer with two node.
Don't see any error in the log file.
If you read how mod_rewrite works you'd see that you're not grouping the regex properly if you need the full request string... You'd need something like this....

Code:
<Proxy balancer://2node-aa>
  BalancerMember https://app02:8080 route=node2
</Proxy>
RewriteRule ^(/aa/login/.*)$ balancer://2node-aa$1 [P]
Notice now I grouped the RewriteRule. Before you had...
Code:
RewriteRule ^/aa/login/(.*)$ balancer://2node-aa$1 [P]
which means if someone visited http://example.com/aa/login/some/url then what would be passed to the proxy server is "some/url". Where the following actually passes "/aa/login/some/url" like you would expect.
Code:
RewriteRule ^(/aa/login/.*)$ balancer://2node-aa$1 [P]
You should really read the documentation to understand the solution provided to you and then adjust the solution to what you actually want. In your case the %{REQUEST_URI} will cover the whole URI so the parenthesis are no longer needed in the RewriteRule string. See apache documentation on mod_rewrite.

SAM
 
  


Reply

Tags
apache



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Balancer using Apache Reverse Proxy sarthak.limbachia Linux - Newbie 1 12-14-2012 01:13 PM
[SOLVED] Apache Tomcat - Load Balancer czezz Linux - Server 1 09-21-2011 06:37 AM
squid proxy with multi wan links and load balancer lukeshih Linux - Networking 1 03-02-2010 09:10 AM
Apache-ajp Proxy Balancer: request is not switching from one instance to another singh.lovelesh Linux - Server 0 10-08-2009 02:35 AM
Apache Load Balancer. nishith Linux - Networking 1 09-19-2008 08:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration