Jump to content

Recommended Posts

Posted

I thought I had my pac file sorted but they do not seem to be working? (Windows 8.1 IE 11 and Chrome)

I want a pac file that only uses the proxy when on the local network and has acceptations for other local address.

 

Also does a pac have to be hosted on a webserver or can it be run form a local drive?

Posted

Is this proxy pac correct? it don't seem to be working?

 

function FindProxyForURL(url, host)

{ if (isInNet(myIpAddress(), "10.0.0.0", "255.255.0.0"))

return "PROXY proxy-01:8080; DIRECT";

else return "DIRECT";

 

if ( dnsDomainIs (host,"host1.local") ||

dnsDomainIs ("host2.local") ||

dnsDomainIs (host,"host3.local"))

return "DIRECT";

 

if (isInNet(host, "10.0.0.0", "255.0.0.0"))

return "DIRECT";

}

Posted

Not had much experience with PAC files before but the js code looks a little off to me..

 

The function will terminate as soon as it hits a return statement so only the first if statement will ever be evaluated in it's current form I think.. Give me a bit of time and I'll try reformatting it a bit for you to see if that helps..

Posted (edited)
I thought I had my pac file sorted but they do not seem to be working? (Windows 8.1 IE 11 and Chrome)

I want a pac file that only uses the proxy when on the local network and has acceptations for other local address.

 

Also does a pac have to be hosted on a webserver or can it be run form a local drive?

 

Dredged this up from storage, was working as you propose at the time:

 

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, "*.lea.gov.uk*")) { return proxy_no; }
if (shExpMatch(url, "http://localhost*")) { return proxy_no; }
if (shExpMatch(url, "http://serverwhatever*")) { return proxy_no; }
if (shExpMatch(url, "http://192.nnn.nnn.*")) { return proxy_no; }
// If at school, use proxy
if (isInNet(myIpAddress(), "192.nnn.nnn.0", "255.nnn.nnn.0"))
	return "PROXY WhateverProxyIs:PortNumber";
else
	return "DIRECT";
}

 

It can be stored locally, for example you can use the location: file://c:/windows/proxy.pac . However, the syntax varies from browser to browser - Firefox needs an extra / after "file:" IIRC. Not sure about Chrome!

 

That said, which Server version are you running? You may not need to use a .pac file.

Edited by LeMarchand
Typo
Posted

As a start I've rewritten your code to separate out the if blocks.. and only include a single return. See if this helps.... It may require further changes to actually get it applying the settings correctly for all addresses.

function FindProxyForURL(url, host){
var strProxy;

//
if(isInNet(myIpAddress(), "10.0.0.0", "255.255.0.0")){
	strProxy = "PROXY proxy-01:8080";
} else {
	strProxy = "DIRECT";
}

if ( dnsDomainIs (host,"host1.local") ||
		dnsDomainIs ("host2.local") ||
		dnsDomainIs (host,"host3.local")){
	strProxy = "DIRECT";
}

if (isInNet(host, "10.0.0.0", "255.0.0.0")){ 
	strProxy = "DIRECT";
}

return strProxy;
}

Posted
That said, which Server version are you running? You may not need to use a .pac file.

 

Actually, looking at my current setup/s, the proxied access is controlled by .pac file hosted by the LEA on their webserver which isn't accessible outside of the school so the browsers revert to "Direct" as they are unable to configure.

 

The .pac code should still be good, though!

Posted

This seems to be working how would I tidy it up?

 

function FindProxyForURL(url, host)

{

if (isResolvable(host); " proxy-01")

return "PROXY proxy-01:8080";

 

 

if ( dnsDomainIs (host,"host1.local") ||

dnsDomainIs (host,"host1.local") ||

dnsDomainIs (host,"host1.local"))

return "DIRECT";

 

if (isInNet(host, "10.0.0.0", "255.0.0.0"))

return "DIRECT";

 

else return "DIRECT";

 

}

Posted (edited)

What is this line meant to be doing?

if(isResolvable(host); " proxy-01")

 

I'm guessing it should just be testing whether the host can be resolved through DNS.

 

In which case this should work:

 

function FindProxyForURL(url, host)
{
if (dnsDomainIs(host,"host1.local") ||
		dnsDomainIs (host,"host1.local") ||
		dnsDomainIs (host,"host1.local"))
	return "DIRECT";

if (isInNet(host, "10.0.0.0", "255.0.0.0")) 
	return "DIRECT";

if (isResolvable(host))
	return "PROXY proxy-01:8080";

return "DIRECT";

}

 

It first tests whether the domain is host1.local etc and returns direct if it is. Then test whether it's an address on your subnet and returns direct if it is. If neither of these tests evaluate to true it then checks whether the host is resolvable and if it is returns the proxy to use. If not it returns direct. Is that what you're after?

Edited by spadam
Posted

No it not working must have been caching a working script.

 

if(isResolvable(host); " proxy-01") that was trying to see if the proxy server is resolvable i take it that can only be done like that for ip addresses.

Posted (edited)
No it not working must have been caching a working script.

 

if(isResolvable(host); " proxy-01") that was trying to see if the proxy server is resolvable i take it that can only be done like that for ip addresses.

 

Not certain but to test for that it possibly should be written as:

 

if(isResolvable("proxy-01"))

 

You will still need to restructure the code as shown in my previous post though as otherwise it will return the proxy for all connections as soon as it detects that the proxy is resolvable.

Edited by spadam
Posted

If you host the pac file internally when the browser is not on your network and cannot access the pac file the browser will fail open.

 

Ben

Posted
I think the script worked fine as Google chrome is working but now IE has decided it is going to not work. It will not use the proxy script even though I have it turn on I have turned proxy caching off.

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...