# Why I can't use a Load Balancer configured in Apache ?



## R6exe (Dec 9, 2020)

Hello everyone, as you can see in the title, I'm having some trouble trying to make a load balancer on one of my FreeBSD servers.
I don't know why but the configuration that I'm giving to apache looks fine, because it's giving me a "syntax ok" when I restart the service, but asks me if the service is running, and unfortunately is not. I check in /var/run but doesn't appear.
All I did was just basically edit the default httpd.conf file.
I added this at the end of the file:

```
<VirtualHost *:80>
<Proxy balancer://cluster>
BalancerMember http://192.168.1.25:80
BalancerMember http://192.168.1.26:80
</Proxy>
ProxyPreserveHost on
ProxyPass / balancer://cluster
ProxyPassReverse / balancer://cluster
</VirtualHost>
```
I loaded the necessary modules too to make this work.
I tried using nginx and works perfectly the load balancer, but I would like more to use apache if I can.
Regards and thank you for your help.


----------



## SirDice (Dec 9, 2020)

R6exe said:


> All I did was just basically edit the default httpd.conf file.
> I added this at the end of the file:


Don't do that. Create a file in /usr/local/etc/apache24/Includes. At the end of httpd.conf there's an include line that will load everything automatically from that directory. Name doesn't really matter (it only has to end with *.conf) but I like to use numbers followed by a descriptive name. The numbers will make sure things are loaded in the right order. I typically have a 001_default.conf with a `_default_` virtual host configuration and various other files, one for each website, 002_example.com.conf, 003_www.example.com.conf, etc.

As to why it's not working, look in /var/log/httpd-error.log for reasons. I suspect it's because none of the proxy modules are actually enabled in httpd.conf.


----------



## R6exe (Dec 10, 2020)

SirDice said:


> Don't do that. Create a file in /usr/local/etc/apache24/Includes. At the end of httpd.conf there's an include line that will load everything automatically from that directory. Name doesn't really matter (it only has to end with *.conf) but I like to use numbers followed by a descriptive name. The numbers will make sure things are loaded in the right order. I typically have a 001_default.conf with a `_default_` virtual host configuration and various other files, one for each website, 002_example.com.conf, 003_www.example.com.conf, etc.
> 
> As to why it's not working, look in /var/log/httpd-error.log for reasons. I suspect it's because none of the proxy modules are actually enabled in httpd.conf.


Thank you so much, I followed the errors that gave me in the httpd-error.log file and I've finally make it work.
Regards and cheers!


----------

