Squid setup:
http_port 80
httpd_accel_host 127.0.0.1
httpd_accel_port 8080

httpd_accel_single_host on
httpd_accel_uses_host_header on

redirect_program /usr/local/bin/redirect.sh
redirect_children 20

Redirector script responsible for: