is it explicit or transparent proxy?
if it is explicit, you have to also convert request (i.e. having hostname in uri) to non-proxy formatting request (i.e. not having hostname in uri) and send it out to Internet gateway. you may review http forward proxy codeshare to see how the conversion works.
HTTP Forward Proxy - v3.2
https://devcentral.f5.com/wiki/irules.HTTP-Forward-Proxy-v3-2.ashx
if it is transparent proxy, you can just check hostname and forward it to Internet gateway.
HTTP::host
https://devcentral.f5.com/wiki/iRules.http__host.ashx
forward
https://devcentral.f5.com/wiki/iRules.forward.ashx