Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to setup a load balancer with Apache 2.4 but I can't make it work.

Here's what I wrote in my http.conf file:

<Proxy balancer://pop>
    BalancerMember http://pop1.local/ loadfactor=1
    BalancerMember http://pop2.local/ loadfactor=1
    ProxySet lbmethod=byrequests
</Proxy>

And this is the list of loaded Apache modules:

core mod_so http_core event mod_authn_file mod_authn_core mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_core mod_access_compat mod_auth_basic mod_watchdog mod_reqtimeout mod_filter mod_mime mod_log_config mod_env mod_headers mod_setenvif mod_version mod_proxy mod_proxy_connect mod_proxy_ftp mod_proxy_http mod_proxy_fcgi mod_proxy_scgi mod_proxy_wstunnel mod_proxy_ajp mod_proxy_balancer mod_proxy_express mod_slotmem_shm mod_lbmethod_byrequests mod_lbmethod_bytraffic mod_lbmethod_bybusyness mod_lbmethod_heartbeat mod_unixd mod_heartmonitor mod_status mod_autoindex mod_dir mod_alias mod_rewrite mod_php5

To test, I've setup three VMs, one for load balancer and two for back-end webservers. Using hosts file I introduced three domains in all of the machines:

192.168.0.100   pop.local
192.168.0.101   pop1.local
192.168.0.102   pop2.local

pop.local is my load balancer and other two are the back-ends. Having a info.php file created on each of the back-ends, I can load them entering http://pop1.local/info.php and http://pop2.local. But when I type http://pop.local, a 404 File not found error returns.

The Apache on pop.local loads normally as if there's no Proxy balancer is set. It can even serve its own local files without a problem.

What's the problem? Am I missing something?

[UPDATE]

Here's the contents of my log file:

error_log:

[Wed Oct 02 02:40:55.530051 2013] [lbmethod_heartbeat:notice] [pid 2179:tid 140142625933120] AH02282: No slotmem from mod_heartmonitor
[Wed Oct 02 02:40:55.541737 2013] [mpm_event:notice] [pid 2179:tid 140142625933120] AH00489: Apache/2.4.6 (Unix) PHP/5.5.1 configured -- resuming normal operations
[Wed Oct 02 02:40:55.541768 2013] [core:notice] [pid 2179:tid 140142625933120] AH00094: Command line: '/usr/local/apache2/bin/httpd'
[Wed Oct 02 02:42:04.170782 2013] [:error] [pid 2615:tid 140142199158528] [client 192.168.0.81:55732] script '/usr/local/apache2/htdocs/info.php' not found or unable to stat
share|improve this question
    
What do your logs say? –  Jenny D Oct 2 '13 at 10:05
    
I'll update the question. –  Mehran Oct 2 '13 at 10:06
    
What's up with the negative vote!? –  Mehran Oct 2 '13 at 10:23
    
Which of the servers was the logfile from? –  Jenny D Oct 2 '13 at 10:39
1  
I'm missing the ProxyPass line in your config. –  Jenny D Oct 2 '13 at 10:46

1 Answer 1

up vote 1 down vote accepted

Here's a complete balancer config that should work:

<Proxy balancer://pop>
    BalancerMember http://pop1.local/ loadfactor=1
    BalancerMember http://pop2.local/ loadfactor=1
    ProxySet lbmethod=byrequests
</Proxy>
ProxyPass / balancer://pop/

As stated in documentation, if the first part of ProxyPass ends with a / the second part also needs to end with the /:

If the first argument ends with a trailing /, the second argument should also end with a trailing / and vice versa. Otherwise the resulting requests to the backend may miss some needed slashes and do not deliver the expected results.

You also need to make sure that ProxyRequests is set to off.

share|improve this answer
    
Just don't forget the / at the end of ProxyPass. Thanks again. –  Mehran Oct 2 '13 at 13:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.