Forum Discussion

Luca_55898's avatar
Luca_55898
Icon for Nimbostratus rankNimbostratus
Jul 05, 2011

Using an iRule for a proxy pac file

Trying to get an iRule working to deploy a proxy pac file.

 

I have been reading this link http://devcentral.f5.com/wiki/default.aspx/iRules/Proxy_Pacfile_Hosting_without_need_for_Web_servers.html and have created the iRule below based on the version 10 source in the link above.

 

 

So I understand that the 'return DIRECT' will bypass the proxy for all the sites listed in the shExpMatch section. But what about going onto the internet, which section of the iRule determines that www.microsoft.com for example needs to be assigned proxy1.ourbusiness.com?

 

 

Also, the devcentral link above says to just create the VIP but do not assign any pool, is that correct?

 

 

So apart from my questions above, does the rule below look OK? If i just point a client to the IP of the vip on whatever port the VIP listens on, such as http://192.1.1.1:8080/proxy.pac will that work?

 

 

 

when RULE_INIT {

 

set static::pacfile {

 

function FindProxyForURL(url, host) {

 

 

if (isPlainHostName(host))

 

return "DIRECT";

 

 

if (shExpMatch(url,"*.messages.*") ||

 

shExpMatch(url,"*remote.ourbusiness.com.au*") ||

 

shExpMatch(url,"*ww.ourbusiness.com.au*"))

 

shExpMatch(url,"*gobusiness.*") ||

 

shExpMatch(url,"*firstcust.*") ||

 

shExpMatch(url,"*longday.*") ||

 

shExpMatch(url,"*rosshome.*") ||

 

shExpMatch(url,"*ourbusiness.com*") ||

 

shExpMatch(url,"*portal.ourbusiness.com.au*") ||

 

shExpMatch(url,"*ourbusiness.com.au*") ||

 

shExpMatch(url,"*w2.ourbusiness.com.au*") ||

 

shExpMatch(url,"*w3.ourbusiness.com.au*") ||

 

shExpMatch(url,"*msgpooled.com*") ||

 

shExpMatch(url,"*corporateorders.com*") ||

 

shExpMatch(url,"*generic.com.au*") ||

 

shExpMatch(url,"*.ecommerce.com*") ||

 

shExpMatch(url,"*.paymentpage.com*") ||

 

shExpMatch(url,"*.mpt.com.*") ||

 

shExpMatch(url,"*.customercentral.com*") ||

 

shExpMatch(url,"*.informatic.com*"))

 

return "DIRECT";

 

 

if (dnsDomainIs(host, ".extranet.com")||

 

dnsDomainIs(host, ".extranet2.com"))

 

return "Proxy proxy1.ourbusiness.com:8080";

 

 

if (dnsDomainIs(host, ".intrant.com")||

 

dnsDomainIs(host, ".intranet2.com"))

 

return "DIRECT";

 

 

return "PROXY proxy1.ourbusiness.com:8080";

 

}

 

}

 

}

 

 

when HTTP_REQUEST {

 

switch [HTTP::uri] {

 

"/proxy.pac" {

 

HTTP::respond 200 content $static::pacfile "Content-Type" "application/x-ns-proxy-autoconfig" "pragma" "no-cache"

 

}

 

}

 

}