Server being overloaded by flood attack [duplicate]

Fail2ban might be a good option to watch the apache access LOG for unusual amounts of HEAD requests in a given period of time and create a temporary block in iptables firewall.

Jay Ta'ala has an article on his website that provides information on how to configure fail2ban for watching apache log files.