Scenario: I work for a public library and we use a paid database to access grant information. Part of our SLA is that users must access the site from one specified IP Address. The user must physically be at one of our locations and the password can’t be stored on the PC. They provided three address that are slightly different from their normal url. The addresses provided to us end with “ipl”. Once one of our users tries to access it, their system will verify the incoming IP Address and if it matches what we provided, it will grant the user access.
To accomplish this we decided to implement an on-premise proxy server. Each PC will be configured to access the proxy server via a .pac file. The file will only send traffic to the proxy sever if the user tries to access any of the three sites. All other traffic will go out through our regular router.
Issue: Some of the sites are not working as expected. Some sites are proxied as expected and others are not. From my research it appears there maybe some type of syntax error using dnsDomainIs and shExpMatch. For instance www.cnn.com, www.tesla.com, www.yahoo.com, work just fine. In the same script, if I replace those with the provided URL’s they don’t work as expected.
If I use the addresses, in a browser, on the proxy sever, it works as expected.
Sample Script:
- The last three sites are the exact URL’s as provided. The others were just chosen to see if they would work.
- I intentionally changed the proxy server name to 0.0.0.0
function FindProxyForURL(url, host) {
// Your proxy server name and port
var proxyserver = ‘0.0.0.0:8080';
//
// Here's a list of hosts to connect via the PROXY server
//
var proxylist = new Array(
"www.tesla.com",
"www.monster.com",
"www.cnn.com",
"www.yahoo.com",
"https://fconline.foundationcenter.org/ipl.php",
"https://grantstoindividuals.org",
"https://www.guidestar.org/ipl"
);
// Return our proxy name for matched domains/hosts
for(var i=0; i<proxylist.length; i++) {
var value = proxylist[i];
if ( localHostOrDomainIs(host, value) ) {
return "PROXY "+proxyserver;
}
}
return "DIRECT";
}
Any assistance with getting this script to work correctly would be greatly appreciated.
Thanks
You have to match host names, not URLs. Start by removing
https://and ther URL path (/file.ext) from the URLs you want to proxy. You also have a "smart quote" around0.0.0.0:8080, you need to use plain ASCII single quotes (') in JavaScript.This PAC file could be simplified quite a bit. Something like: