A PAC file is a specialized JavaScript function definition that a browser calls to determine how requests are handled. Clients must specify (in their browser settings) the URL from which the PAC file is loaded. You can store a PAC file on web Server (or on any server in your network) and then provide the URL for this file to your clients.
NOTE:
You should save the JavaScript function to file with a .pac filename extension; for example: proxy.pac
You should save the JavaScript function by itself, not embed it in HTML.
Next, if you are using web server to hold your pac file, you should configure your web server to map the .pac filename extension to the MIME type: application/x-ns-proxy-autoconfig
In apache (for example) put the following in your mime.types file
application/x-ns-proxy-autoconfig pacFirefox Browser Configuration:
Go to Edit > Preferences > Advance (Network > Settings)
The client machines download the script when they startup from a web server. This web server has to serve the file as a different mime-type. The Auto-Config script is normally a .pac file, so if you aren't already using this for something else you should put the mime type in your mime config file for your web server.
Sample PAC File
The following sample PAC file instructs browsers to connect directly to all hosts without a fully-qualified domain name and to all hosts in the local domain. All other requests go to the Proxy Server named myproxy.company.com.
function FindProxyForURL(url, host)
{
if (isInNet(host, "192.168.1.0", "255.255.255.0")) {
return "DIRECT";
} else {
if (shExpMatch(url, "http:*"))
return "PROXY myproxy.company.com:3128" ;
if (shExpMatch(url, "https:*"))
return "PROXY myproxy.company.com:3128" ;
if (shExpMatch(url, "ftp:*"))
return "PROXY myproxy.company.com:3128" ;
return "DIRECT";
}
}
{
if (isInNet(host, "192.168.1.0", "255.255.255.0")) {
return "DIRECT";
} else {
if (shExpMatch(url, "http:*"))
return "PROXY myproxy.company.com:3128" ;
if (shExpMatch(url, "https:*"))
return "PROXY myproxy.company.com:3128" ;
if (shExpMatch(url, "ftp:*"))
return "PROXY myproxy.company.com:3128" ;
return "DIRECT";
}
}
0 comments:
Post a Comment