Reputation: 69
We have a requirement in out environment where apache web server is installed, in which ssl and non-ssl port is configured to listen on 8080 and 4443 respectively. Now i want to load balance the request based on input, if the incoming request is ssl it should load balance the request to "https" and if its non-ssl it should load balance the request to "http". Have tried the below method but its not working as expected. Can someone help?
<Proxy balancer://mybalancerhttp>
BalancerMember http://localhost1/
BalancerMember http://localhost2/
ProxySet lbmethod=byrequests
</Proxy>
ProxyPass / "balancer://mybalancerhttp/"
ProxyPassReverse / "balancer://mybalancerhttp/"
<Proxy balancer://mybalancerhttps>
BalancerMember https://localhost1/
BalancerMember https://localhost2/
ProxySet lbmethod=byrequests
</Proxy>
ProxyPass / "balancer://mybalancerhttps/"
ProxyPassReverse / "balancer://mybalancerhttps/"
Thanks
Upvotes: 1
Views: 4954
Reputation: 1156
I had a similar problem (/balancer-manager only worked on HTTP, not on HTTPS), and in my case the solution turned out to be to add this configuration in file "ssl.conf" instead of "httpd.conf".
Upvotes: 0
Reputation: 2890
Those directives are fine, but you want to decide where to send based on client request.
The easiest method is to move each of those proxypass sets and their balancer definition to their own virtualhost.
This is
<VirtualHost *:8080>
ServerName yourhostname.example.com
<Proxy balancer://mybalancerhttp>
BalancerMember http://localhost1/
BalancerMember http://localhost2/
ProxySet lbmethod=byrequests
</Proxy>
ProxyPass / "balancer://mybalancerhttp/"
ProxyPassReverse / "balancer://mybalancerhttp/"
</VirtualHost>
<VirtualHost *:4443>
ServerName yourhostname.example.com
SSLEngine on
SSLProxyEngine on
....certs and all needed directives
<Proxy balancer://mybalancerhttps>
BalancerMember https://localhost1/
BalancerMember https://localhost2/
ProxySet lbmethod=byrequests
</Proxy>
ProxyPass / "balancer://mybalancerhttps/"
ProxyPassReverse / "balancer://mybalancerhttps/"
</VirtualHost>
Upvotes: 2