If a virtualhost configured behind a load balancer originated http/https, requests using the proxy module in destination to the Internet IP of the virtual host, the route of the packet would then have to be:
Vhost ==ProxyModule==>> LoadBalancer ==>> Loop to itself ==>> Vhost
For technical reasons I needed to avoid this route. This route is often blocked by either the firewall or the load balancer itself or both.
The reason being that packets originating from behind the load balancer might be not be allowed to reverse traverse the load balancer, direction Internet, and then loop back exactly to itself. The load balancer is often seeing these packets as spoofing packets and discards them.

Vhosts configured in web server with IP:

One of the best solution to this is to add a few entries in the /etc/hosts in each web server as follows, which makes the Apache proxy module send requests to its internal IP. ......
After restarting Apache, it will send all requests destinated to itself or another local vhost (sent via proxy) to the local configured IP instead of to Internet and back in. This will avoid the blockage from the Loadbalancer or Firewall.

But what about if the Load balancer does port NATting and your vhosts are configured to use for example the port 8080(http) and(8081)https. The above /etc/hosts trick would not work. Then use the SOLUTION 2.

Use iptables rules to do ‘port forwarding’ as follows:

apt-get install iptables-persistent
iptables -t nat -A OUTPUT -d -p tcp -m tcp --dport 80 -j DNAT --to-destination
iptables -t nat -A OUTPUT -d -p tcp -m tcp --dport 443 -j DNAT --to-destination
iptables-save > /etc/iptables/rules

The next time you reboot, the iptables rule will automatically be loaded.

%d bloggers like this: