LinuxQuestions.org
Review your favorite Linux distribution.
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 05-22-2014, 05:47 AM   #1
greyarea
LQ Newbie
 
Registered: Jan 2008
Distribution: Centos5/RHEL5
Posts: 27

Rep: Reputation: 0
Apache Load Balancer


Hello,

I am trying to set up a load balancer in Apache 2.2.15 in the follwing configuration:

Code:
                          |- Node1
Client <--> Balancer <--> |- Node2
                          |- Node3
                          |- Node4
My balancer configuration in the Virtual Host configuration file is like this:

Code:
#       ProxyRequests Off
#       <Proxy *>
#         Order Deny,Allow
#         Deny from all
#       </Proxy>

        ProxyPass / balancer://sitea/
        ProxyPassReverse / balancer://sitea/
        #ProxyPreserveHost On

        <Proxy balancer://sitea>
          BalancerMember http://aas-poc-sitea-node1.emcpoc.local:80
          BalancerMember http://aas-poc-sitea-node2.emcpoc.local:80
          BalancerMember http://aas-poc-sitea-node3.emcpoc.local:80
          BalancerMember http://aas-poc-sitea-node4.emcpoc.local:80
          ProxySet stickysession=BALANCERID
        </Proxy>
The problem I have is that the load balancer works but the balanced nodes (Node1-4) return a 301 Permanently Moved, the client browser then attempts to connect directly to the back-end node, which is not possible.

I understood that the ProxyPassReverse directive would prevent this. I have found that uncommenting the ProxyPreserveHost directive retains the correct URL but then the target page is not returned at all.

How can I force traffic to go through the balancer and prevent the client trying to follow the new URL in the 301 message?

Thanks,

Last edited by greyarea; 05-22-2014 at 05:51 AM.
 
Old 05-22-2014, 06:25 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,887
Blog Entries: 4

Rep: Reputation: 3999Reputation: 3999Reputation: 3999Reputation: 3999Reputation: 3999Reputation: 3999Reputation: 3999Reputation: 3999Reputation: 3999Reputation: 3999Reputation: 3999
Not sure, but do you know that all of the URLs listed in BalanceMember are correctly resolved?
 
Old 05-23-2014, 04:35 AM   #3
greyarea
LQ Newbie
 
Registered: Jan 2008
Distribution: Centos5/RHEL5
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
do you know that all of the URLs listed in BalanceMember are correctly resolved?
Yes, they can be resolved by the balancer - confirmed on the console.


I have since been advised by the vendor that I should only be proxying/balancing requests to the /rest subdirectory. I have modified my configuration accordingly but am still having issues - modified config & log file below

Code:
        ProxyRequests Off

        ProxyPass /rest balancer://cluster/
        ProxyPassReverse /rest http://aas-poc-sitea-node1.emcpoc.local/rest
        ProxyPassReverse /rest http://aas-poc-sitea-node2.emcpoc.local/rest
        ProxyPassReverse /rest http://aas-poc-sitea-node3.emcpoc.local/rest
        ProxyPassReverse /rest http://aas-poc-sitea-node4.emcpoc.local/rest
        ProxyPreserveHost On

        <Proxy balancer://cluster>
          BalancerMember http://aas-poc-sitea-node1.emcpoc.local
          BalancerMember http://aas-poc-sitea-node2.emcpoc.local/rest
          BalancerMember http://aas-poc-sitea-node3.emcpoc.local/rest
          BalancerMember http://aas-poc-sitea-node4.emcpoc.local/rest
          ProxySet stickysession=BALANCERID
        </Proxy>

Code:
[Fri May 23 10:12:27 2014] [debug] mod_proxy_balancer.c(46): proxy: BALANCER: canonicalising URL //cluster/
[Fri May 23 10:12:27 2014] [debug] mod_proxy_balancer.c(280): proxy: BALANCER: Found value (null) for stickysession BALANCERID
[Fri May 23 10:12:27 2014] [debug] mod_proxy_balancer.c(1021): proxy: Entering byrequests for BALANCER (balancer://cluster)
[Fri May 23 10:12:27 2014] [debug] mod_proxy_balancer.c(1064): proxy: byrequests selected worker "http://aas-poc-sitea-node2.emcpoc.local" : busy 0 : lbstatus -1
[Fri May 23 10:12:27 2014] [debug] mod_proxy_balancer.c(581): proxy: BALANCER (balancer://cluster) worker (http://aas-poc-sitea-node2.emcpoc.local) rewritten to http://aas-poc-sitea-node2.emcpoc.local/
[Fri May 23 10:12:27 2014] [debug] mod_proxy.c(1020): Running scheme balancer handler (attempt 0)
[Fri May 23 10:12:27 2014] [debug] mod_proxy_http.c(1962): proxy: HTTP: serving URL http://aas-poc-sitea-node2.emcpoc.local/
[Fri May 23 10:12:27 2014] [debug] proxy_util.c(2026): proxy: HTTP: has acquired connection for (aas-poc-sitea-node2.emcpoc.local)
[Fri May 23 10:12:27 2014] [debug] proxy_util.c(2082): proxy: connecting http://aas-poc-sitea-node2.emcpoc.local/ to aas-poc-sitea-node2.emcpoc.local:80
[Fri May 23 10:12:27 2014] [debug] proxy_util.c(2209): proxy: connected / to aas-poc-sitea-node2.emcpoc.local:80
[Fri May 23 10:12:27 2014] [debug] proxy_util.c(2460): proxy: HTTP: fam 2 socket created to connect to aas-poc-sitea-node2.emcpoc.local
[Fri May 23 10:12:27 2014] [debug] proxy_util.c(2592): proxy: HTTP: connection complete to 172.16.117.32:80 (aas-poc-sitea-node2.emcpoc.local)
[Fri May 23 10:12:27 2014] [debug] mod_proxy_http.c(1732): proxy: start body send
[Fri May 23 10:12:27 2014] [debug] mod_proxy_http.c(1836): proxy: end body send
[Fri May 23 10:12:27 2014] [debug] proxy_util.c(2044): proxy: HTTP: has released connection for (aas-poc-sitea-node2.emcpoc.local)
[Fri May 23 10:12:27 2014] [debug] mod_proxy_balancer.c(622): proxy_balancer_post_request for (balancer://cluster)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Apache Jboss load balancer issue say_hi_ravi Linux - Server 0 07-19-2010 04:26 AM
Apache Load Balancer. nishith Linux - Networking 1 09-19-2008 08:00 AM
using mod_backhand as a load balancer with apache subhasis_ray Linux - Networking 0 09-23-2002 03:11 PM

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

All times are GMT -5. The time now is 09:08 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