Jump to content

Recommended Posts

Posted

function FindProxyForURL(url, host)
{
//Variable strings to return
var proxy_no = "DIRECT";
//If specific URL needs to bypass proxy, send traffic direct
//	if (shExpMatch(url, "http://www.LEA.gov.uk*")) { return proxy_no; }
             if (shExpMatch(url, "http://access.LEA.gov.uk*")) { return proxy_no; }
if (shExpMatch(url, "http://corp-intranet.LEA.gov.uk*")) { return proxy_no; }	
if (shExpMatch(url, "http://intranet.LEA.gov.uk*")) { return proxy_no; }
if (shExpMatch(url, "http://citrixschools.LEA.gov.uk*")) { return proxy_no; }
if (shExpMatch(url, "http://192.School.IPRange.*")) { return proxy_no; }
if (shExpMatch(url, "http://localhost*")) { return proxy_no; }
// If at school, use proxy
if (isInNet(myIpAddress(), "192.School.IPRange.0", "255.255.255.0"))
	return "PROXY proxy.address:8080";
else
	return "DIRECT";
}

 

It could probably be simpler, but it seems to work. You may not need as many exceptions!

  • Thanks 1
Posted

Sure, well strictly speaking this is our wpad.dat file but its the same

 

function FindProxyForURL(url, host){

if (

isInNet(host, "", ") ||

isPlainHostName(host) ||

localHostOrDomainIs(host, "127.0.0.1") ||

dnsDomainIs(host, "")

){

return "DIRECT";

}

 

 

else

return "PROXY ";

}

Posted
function FindProxyForURL(url, host)
{
//Variable strings to return
var proxy_no = "DIRECT";
//If specific URL needs to bypass proxy, send traffic direct
//	if (shExpMatch(url, "http://www.LEA.gov.uk*")) { return proxy_no; }
             if (shExpMatch(url, "http://access.LEA.gov.uk*")) { return proxy_no; }
if (shExpMatch(url, "http://corp-intranet.LEA.gov.uk*")) { return proxy_no; }	
if (shExpMatch(url, "http://intranet.LEA.gov.uk*")) { return proxy_no; }
if (shExpMatch(url, "http://citrixschools.LEA.gov.uk*")) { return proxy_no; }
if (shExpMatch(url, "http://192.School.IPRange.*")) { return proxy_no; }
if (shExpMatch(url, "http://localhost*")) { return proxy_no; }
// If at school, use proxy
if (isInNet(myIpAddress(), "192.School.IPRange.0", "255.255.255.0"))
	return "PROXY proxy.address:8080";
else
	return "DIRECT";
}

 

It could probably be simpler, but it seems to work. You may not need as many exceptions!

 

How can i modify this to include more than one ip range please?

 

Thanks

Posted
function FindProxyForURL(url, host)
{
// See http://www.microsoft.com/technet/prodtechnol/ie/ieak/techinfo/deploy/60/en/corpexjs.mspx?mfr=true for examples
var proxyServer = "upstreamproxy.mydomain.com:8080";
var bypassList = new Array("exclude1,anotherignoresite.*");

// Check URL against bypass list
for (var i = 0; i < bypassList.length; i++)
{
	var bypassUrl = bypassList[i];
	// Care! see http://support.microsoft.com/kb/274204 if targeting older versions of IE
	if (shExpMatch(host, bypassUrl)) {return "DIRECT";}
}

// All other requests go through to the proxy.
// should that fail to respond, try direct instead
return "PROXY " + proxyServer + "; DIRECT";
}

Posted
How can i modify this to include more than one ip range please?

 

Thanks

 

You should be able to add exceptions in by just adding another line with the appropriate range:

 

if (shExpMatch(url, "http://xxx.xxx.xxx.*")) { return proxy_no; }

 

As for adding an extra range to use the/another proxy, I've not done it myself, but I would imagine that you could just add in another if statement:

 

// If at school, use proxy
if (isInNet(myIpAddress(), "192.School.IPRange.0", "255.255.255.0"))
	return "PROXY proxy.address:8080";
          // If at location Y
             if (isInNet(myIpAddress(), "An.other.range.0", "another.subnet.mask.0"))
	return "PROXY TheRelevant.address:AndPort";   
else
	return "DIRECT";
}

 

The range number must terminate in a 0.

 

P.S. The first line of exceptions in my initial example is commented out for some reason (maybe it's no longer needed, but I left it there as a reminder). Obviously, the // should be removed for it to work.

Posted (edited)

I have been trying to get this proxy.pac working for our laptops and I have just drawn a complete blank. The code I am using is quite simple.

 

function FindProxyForURL(url, host){
if (isInNet(myIpAddress(), “10.0.48.0?, “255.255.252.0?))
return “PROXY staffproxy.swgfl.org.uk:8080?;
else
return “DIRECT”;
}

 

I have followed several on-line guides all of which are very similar. I have created a second site on my IIS server called "pac" because port 80 was in use I have used port 1500. I have deployed a gpo looking to http://server-ip:1500/proxy.pac That works but the proxy settings are not applied.

 

I have also tried using wpad.dat and entering a cname entry that fails too.

 

All our clients are Windows 7 with IE8 our servers are 2008R2, the proxy server we use is offsite. Is there an alternative way of getting this solution?

 

Also if I enter the file locations directly in the browser that doesn't work either.

Edited by edie209
more info
Posted

Assuming those question marks are typos (they should be quotation marks - "), have you tried storing the PACs locally?

 

I have to confess that I've never got around to properly publishing the PACs and script a "copy to" location X and use a GPO to point the browser to the file, e.g. file://C:\ProxySettings\MyProxy.pac.

 

If nothing else, you could use this on a test machine to check whether it's a problem with the PAC or the publishing method. Ignore me if that's what you meant by:

 

Also if I enter the file locations directly in the browser that doesn't work either.
Posted

Easiest way to do this is with wpad.

I have also tried using wpad.dat and entering a cname entry that fails too.

Its an A record you need.

Plus not all browsers work the same - can't remember off the top of my head by some only do dns wapd, some only dhcp wapd, some both - so its worth setting up dhcp + dns methods.

Here is a fairly straight forward guide: Deploying WPAD « FindProxyForURL - Proxy PAC & WPAD Resource

Posted

Thanks for the replies guys

 

I have got it working using a different method but not dissimilar to what you suggested LeMarchand, this way I don't have to put the file on each machine.

 

 

 

user - windows - internet explorer maintenance - automatic browser configuration - enable automatic configuration enabled

 

Automatic proxy url (.js .jvs or .pac file) file://\\location-of-share\wpad.dat

 

 

Only thought I have had iswhat happens when it can't see the share? does the browser just assume there are no proxy settings.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...