MrMarkT Posted May 2, 2012 Posted May 2, 2012 Good morning Gents/Ladies i have been given the task from my company to create a PAC file for our corporate laptop users. All i need the PAC file to do is to detect that if the user is at work their web traffic will get pointed to our internal proxy if at home to go DIRECT. This is what i have. function FindProxyForURL (url, host) { return "PROXY 192.168.10.65:8080; DIRECT"; } My biggest gripe is that if the user is at home it takes upwards of 40 seconds for the PAC file to timeout from not detecting the internal web proxy. Can anyone please give me a fix it would be greatly appreciated Thanks, Mark
nickbro Posted May 2, 2012 Posted May 2, 2012 If they restart the browser, it should find that it can't connect to the pac file to download it and will go direct. Here's my PAC file function FindProxyForURL(url, host) { if (shExpMatch(url, "ftp:*")) return "DIRECT"; // If IP address is internal or hostname resolves to internal IP, send direct. var resolved_ip = dnsResolve(host); if (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0") || isInNet(resolved_ip, "172.16.0.0", "255.240.0.0") || isInNet(resolved_ip, "192.168.0.0", "255.255.0.0") || isInNet(resolved_ip, "127.0.0.0", "255.255.255.0")) return "DIRECT"; return "PROXY rmsmartcache.local:8080; PROXY adsl.local:3128; DIRECT"; } We also advertise the pac file via DHCP, do the laptops staff bring in don't need to configure there laptop if they have auto detect ticked
MrMarkT Posted May 2, 2012 Author Posted May 2, 2012 If they restart the browser, it should find that it can't connect to the pac file to download it and will go direct. Here's my PAC file function FindProxyForURL(url, host) { if (shExpMatch(url, "ftp:*")) return "DIRECT"; // If IP address is internal or hostname resolves to internal IP, send direct. var resolved_ip = dnsResolve(host); if (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0") || isInNet(resolved_ip, "172.16.0.0", "255.240.0.0") || isInNet(resolved_ip, "192.168.0.0", "255.255.0.0") || isInNet(resolved_ip, "127.0.0.0", "255.255.255.0")) return "DIRECT"; return "PROXY rmsmartcache.local:8080; PROXY adsl.local:3128; DIRECT"; } We also advertise the pac file via DHCP, do the laptops staff bring in don't need to configure there laptop if they have auto detect ticked Thank you for your quick reply!! With response to your reply our Network Ip ranges are all class c so conflict does happen if the user's router/modem at home also users the same class c range. I was thinking about using if (isInNet(myIpAddress, "192.168.subnet.0", "255.255.255.0")) || (isInNet(myIpAddress, "192.168.anothersubnet.0", "255.255.255.0")) || etc... The only problem is that we have about 20 subnets, curious to whether it may lag checking all the ranges. Will let you know
nickbro Posted May 2, 2012 Posted May 2, 2012 No lag at all, the checks on all of the internal ranges, which are communally internal networks which don't need/want to go via a proxy server. If your using something like http://wpad.local/wpad.pac as the config address, when the PC is at home, when the browser first starts up and doesn't find the PAC file, it should default back to "DIRECT", that's a one time hit and it's usually very quick. If you do the 252 DHCP option, as long as the user closes the browser when changing location, IE, and Firefox, will pick up on the network change and go direct instead of loading the PAC file
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now