HowTo: Use Auto Config Proxy PAC File For Specific Domain

https‮w//:‬ww.lautturi.com
HowTo: Use Auto Config Proxy PAC File For Specific Domain

To use an auto-config proxy PAC (Proxy Auto-Configuration) file for a specific domain on a Linux or Unix system, you will need to configure the system to use the PAC file and specify the domain for which it should be used.

Follow these steps to use an auto-config proxy PAC file for a specific domain:

  1. Create a PAC file with the desired proxy configuration. The PAC file should contain a JavaScript function that returns the proxy configuration for a given URL. For example:
function FindProxyForURL(url, host) {
  if (shExpMatch(host, "domain.com")) {
    return "PROXY proxy.example.com:3128";
  }
  return "DIRECT";
}

This PAC file will use the proxy.example.com:3128 proxy for requests to domain.com, and direct connections for all other requests.

  1. Save the PAC file to a location on the system, such as /etc/proxy.pac.

  2. Configure the system to use the PAC file by setting the http_proxy environment variable to the URL of the PAC file. For example:

export http_proxy=http://localhost/etc/proxy.pac

This will configure the system to use the PAC file for all HTTP connections.

  1. To use the PAC file only for specific domains, you can use the no_proxy environment variable to specify a list of domains for which the PAC file should not be used. For example:
export no_proxy="localhost,127.0.0.1,*.local"

This will exclude the local domains from the proxy configuration specified in the PAC file.

Created Time:2017-10-29 22:08:46  Author:lautturi