Proxy pacfile hosting without need for Webservers using iFiles on v11
Problem this snippet solves: The following is an iRule that allows the F5 to serve a proxy pac file to a client without the need of hosting it on a web server or the proxy itself.
Simply create th...
Published Mar 18, 2015
Version 1.0The_Bhattman
Nimbostratus
Joined October 14, 2005
The_Bhattman
Nimbostratus
Joined October 14, 2005
Brian_Dantzig
Aug 13, 2015Nimbostratus
I have been doing a similar thing for years and it works well. On problem we had with the PAC file was that we made some decisions based on what the IP of the client is. Our PAC file use "var LocalIP = myIpAddress();" to get the IP but this may be unreliable. Systems that have more than one IP such as a wired and wireless or more troublesome for us were VPN connected users. Our logic would fail because sometimes the PAC file would see the Public rather than the VPN address and make the wrong decision. Our fix was to have the LTM get the address using "[IP::client_addr]" and replace the line in the PAC file using something like:
when HTTP_REQUEST {
Get the PAC from the iFile
set response [ifile get proxy_pac]
rewrite the pac file on the fly to fix problem with getting the correct IP
Create a string with a command javascript command to set a var to the client IP
append replacement {var LocalIP = "} [IP::client_addr] {";}
Replace the command in the pac file with the new command
regsub -line {var LocalIP = .*;} $response $replacement response
HTTP::respond 200 content $response "Content-Type" "application/x-ns-proxy-autoconfig"
}