Advantages of a Proxy Auto-Configuration (PAC) File

art graffiti brush abstract

If you send data requests via multiple proxies – or just one proxy – a Proxy Auto-Configuration (PAC) file can give you an easy way to route your traffic. It saves you the work of manually telling your browser whether to use a proxy server, and if so what proxy server hostname and port to use. Let’s explore the advantages of a proxy auto-configuration (PAC) file.

How does it work?

Using a JavaScript function called FindProxyForURL, PAC files (often called “proxy.pac“) can determine where web browser requests (HTTP, HTTPS, and FTP) are sent.

If you’re only using a single proxy, this function simply tells your browser to always use that specific proxy server hostname and port for all requests. But the function can also restrict proxy usage based on the request. For example, a proxy server might only support HTTP requests, but not HTTPS requests. 

In that case, the function would examine the request, and if it’s for a HTTPS URL, it would tell the browser to skip the proxy and go directly to the site. However, a request for a normal HTTP URL would use the proxy. 

Many proxy services, such as ProxyMesh, support both HTTP requests and HTTPS requests, and so the proxy.pac auto-configuration function will work for both an HTTP proxy server and an HTTPS proxy server, but will ignore any non-HTTP/HTTPS requests.

How to use it with an authenticated proxy server?

PAC URLs do not support specification of proxy usernames and passwords. And there’s a good reason: It would be a security risk. Therefore, you must use IP address authentication. A proxy service generally does this for you if you’ve authenticated your IP address in your account.

When you configure your browser, it downloads the PAC file as a local file on your computer. Browsers that open PAC files include those listed below. Follow the links to view configuration steps:

Mobile devices that use standard browsers are also supported.

Once you’ve registered your IP with the proxy server, the  proxy auto-config will handle the rest, by specifying the proxy server hostname and port for each request.

What about multiple proxies?

If you are using a proxy service that provides a PAC file, and you change the proxy servers you use, the service will also provide a way to recreate or update your PAC file. Some services like ProxyMesh allow you to create a PAC that will randomly choose a proxy from a list of many proxy servers. Randomly selecting from multiple proxies is impossible using normal web browser proxy configuration methods.

How to set it up?

First, you need a proxy auto-config URL to use. A good proxy service provides all subscribers with this URL in the account dashboard.

Once you have a URL to auto-config the proxy, you must go into your browser’s proxy or network settings and look for a setting such as Automatic proxy configurationAutoconfiguration URLAutomatic proxy configuration URL, or PAC File URL, and then copy/paste the URL.

Once you save this URL in the settings, your browser will be using the automatic proxy configuration for all future requests – making your request routing easier.

Core Topic: How User Agents Help with Scraping

See also: Understanding IP Geolocation