Difference between revisions of "Proxy PAC"
Jump to navigation
Jump to search
(Created page with "= [https://en.wikipedia.org/wiki/Proxy_auto-config Proxy auto-config | Proxy PAC] = A proxy auto-config (PAC) file defines how web browsers and other user agents can automatically choose the appropriate proxy server (access method) for fetching a given URL. A PAC file contains a JavaScript function FindProxyForURL(url, host). This function returns a string with one or more access method specifications. These specifications cause the user agent to use a particular proxy...") |
|||
Line 34: | Line 34: | ||
// our local URLs from the domains below example.com don't need a proxy: | // our local URLs from the domains below example.com don't need a proxy: | ||
if (shExpMatch(host, "*.foo.acme.com") || | if (shExpMatch(host, "*.foo.acme.com") || | ||
shExpMatch(host, "*.foo- | shExpMatch(host, "*.foo-dev.acme.com") || | ||
shExpMatch(host, "*.foo- | shExpMatch(host, "*.foo-prod.acme.com") || | ||
shExpMatch(host, "*.example.com")) { | shExpMatch(host, "*.example.com")) { | ||
return "PROXY proxy.acme.com:8123"; | return "PROXY proxy.acme.com:8123"; |
Revision as of 11:14, 15 November 2022
Proxy auto-config | Proxy PAC
A proxy auto-config (PAC) file defines how web browsers and other user agents can automatically choose the appropriate proxy server (access method) for fetching a given URL.
A PAC file contains a JavaScript function FindProxyForURL(url, host). This function returns a string with one or more access method specifications. These specifications cause the user agent to use a particular proxy server or to connect directly.
// Option 1 function FindProxyForURL(url, host) { // our local URLs from the domains below example.com don't need a proxy: if (shExpMatch(host, "*.foo.acme.com")) { return "PROXY proxy.acme.com:8123"; } if (shExpMatch(host, "*.foo-dev.acme.com")) { return "PROXY proxy.acme.com:8123"; } if (shExpMatch(host, "*.foo-prod.acme.com")) { return "PROXY proxy.acme.com:8123"; } if (shExpMatch(host, "*.example.com")) { return "PROXY proxy.acme.com:8123"; } // All other requests go through port 8080 of proxy.example.com. // should that fail to respond, go directly to the WWW: return "DIRECT"; } // Option 2 function FindProxyForURL(url, host) { // our local URLs from the domains below example.com don't need a proxy: if (shExpMatch(host, "*.foo.acme.com") || shExpMatch(host, "*.foo-dev.acme.com") || shExpMatch(host, "*.foo-prod.acme.com") || shExpMatch(host, "*.example.com")) { return "PROXY proxy.acme.com:8123"; } // All other requests go through port 8080 of proxy.example.com. // should that fail to respond, go directly to the WWW: return "DIRECT"; }