I saw a tutorial about redirecting client requests to a specific port to a VM inside the server using IPTables.
Is there a way to redirect client requests for foo.com to a VM using only IPTables?
or should I go for squid proxy server?
If foo.com is the only web server listening on that IP, it should be relatively easy, since you would just redirect all port 80 traffic.
If there are other web servers for that IP, you can use string matching in iptables:
but note the caveat in the documentation, about how a proxy would be a better choice.