Pac File Bypass Proxy For Local Addresses

A PAC (Proxy Auto-Configuration) file is a simple JavaScript file that you can use to configure client web browsers to use the Firebox as a proxy server. The PAC file includes the IP address and port number to use to connect to the Firebox. Here is an example of a simple PAC file: function FindProxyForURL(url, host)return 'PROXY 10.0.1.1:3128. How are proxy settings set in the Ubuntu gnome environment. These methods are not full proof and can break the configuration of the system. Making the network behave in an undesired way.

-->

Important

The Internet Explorer 11 desktop application will be retired and go out of support on June 15, 2022 (for a list of what's in scope, see the FAQ). The same IE11 apps and sites you use today can open in Microsoft Edge with Internet Explorer mode. Learn more here.

This topic explains how to optimize the performance of an automatic proxy-configuration script (PAC file, also known as Wpad.dat). This document focuses on how to resolve issues with the intranet servers directly and external internal traffic through a proxy-server.

For more information about the functions that are used to evaluate an address (URL or hostname), see: Use proxy autoconfiguration (.pac) files with IEAK 11.

Note

The isInNet(), isResolvable(), and dnsResolve() functions send queries to the DNS-subsystem. Therefore, you should avoid, or, at least, minimize the use of these functions.

Pac File Bypass Proxy For Local Addresses

Query for NetBIOS names

NetBIOS names (server names that contain no period) are used in the intranet only and are not routed through the proxy:

Query for internal DNS suffixes

Internally used DNS zones are typically routed directly. The easiest way to determine such hosts is by using the dnsDomainis function:

An alternative and faster method for the same result can be obtained by using ShExMatch(). This function does a string compare. It returns the same result but adds an asterisk (*) as a wildcard character:

Query for IP ranges

If the IP address of the host belongs to the local intranet, regardless of the web server name, it should bypass the proxy in order to navigate directly.

If the IP address is entered directly into the address bar, you do not have to resolve it again. You can use the following code to check whether the host is already in the IP address format:

This code checks whether the variable host contains three numerals that are followed by a period and then followed by another numeral. The result is then passed to the variable return. The result is 'true' for an IP and 'false' otherwise.

In the following code snippet, the variable host IP contains the IP address for use in future checks:

When a non-existing host is passed to the function (for example, the user entered something wrong in the address bar), the result in host IP might be zero. Any additional error handling will be done by the proxy:

Because we have the IP address of the host, the internal IP ranges have to be checked.Whenever possible, use the shExpMatch function instead of isInNet. The following code snippets have identical results, although shExpMatch runs faster:

JavaScript is case-sensitive

The proxy script uses the JavaScript language. JavaScript is case-sensitive. Therefore, an if clause that is uppercase will never become true, while other parameters use lowercase. Internet Explorer itself converts the variables host and url into lowercase before the FindProxyForURL function is called.

This condition is not true for WinHTTP. This is because WinHTTP passes the host and the url directly to the function.

Therefore, the parameters that are checked within the PAC file should be converted within the PAC before they are evaluated:

Using IPv6

If you want to use and handle IPv6 addresses, Internet Explorer supports them because Internet Explorer is included in every currently supported Windows version (and in WinHTTP since Windows Vista). However, in this case, you have to use 'Ex' functions (such as isInNetEx()), as mentioned in the following article:

Bypass proxy server for local addresses pac file

For an example of myIpAddressEx implementation, see 'myIpAddress' function returns incorrect result in Internet Explorer 9.

What Is Bypass Proxy Server For Local Addresses

Testing a PAC file

If the script contains any syntax error (for example, a missing ')' character in an if statement), the script is not run. To minimize errors, consider using a script editor that runs syntax checking. By using Visual Studio, you can rename the extension of the PAC file to '.js' during editing, but rename it back to '.pac' before uploading it to the webserver.

Note

Starting in Windows 10, you can no longer use file-based PAC files. For more information, see the following articles:

Testing with Autoprox.exe

Sometimes, you have to test the PAC file even if you have no access to the website. To do this, you can use the Autoprox.exe command line tool.

If you open the tool within a command without using additional parameters, the following output with the help is returned:

Here is the output if it uses our sample:

Error handling in Autoprox.exe

If the PAC file contains syntax errors, you receive the following message:

ERROR: InternetGetProxyInfo failed with error number 0x3eb 1003.

After you finish the local test, you should copy the PAC file to the web server on which it will be accessed through the HTTP protocol.

Example:

Third-party contact disclaimer

Pac File Bypass Proxy For Local Addresses Online

Microsoft provides third-party contact information to help you find additional information about this topic. This contact information may change without notice. Microsoft does not guarantee the accuracy of third-party contact information.