Step-by-Step: Proxy Auto Configuration for Dummies

Written by

in

A Proxy Auto-Configuration (PAC) file is a simple but powerful script that tells your web browser (or operating system) how to connect to the internet. Instead of forcing all your web traffic through one rigid proxy server, a PAC file uses JavaScript rules to route traffic dynamically. For example, it can send traffic to a fast local proxy for company sites, a security filter for international domains, and bypass the proxy entirely for local servers.

Setting up a PAC file means you don’t have to change your network settings every time you switch from the office to your home or a coffee shop. Step 1: Understand the Magic Function

At the heart of every PAC file is a single, mandatory JavaScript function: FindProxyForURL(url, host). When you type a web address or click a link, your browser passes the URL and the host to this script. The script evaluates these values and returns a string dictating the connection method. The return values are usually one of the following: DIRECT: Connect to the website directly (no proxy).

PROXY host:port: Send the request through a specific proxy server.

SOCKS host:port: Route the traffic through a SOCKS firewall/proxy. Step 2: Write Your PAC File Script

A typical PAC file uses basic if/else statements to route traffic. Save your script as plain text with a .pac extension (e.g., proxy.pac). Here is a common example: javascript

function FindProxyForURL(url, host) { // 1. Bypass the proxy for local, internal company domains (e.g., Intranet) if (shExpMatch(host, “.internal.mycompany.com”)) { return “DIRECT”; } // 2. Route all traffic intended for secure corporate assets to a specific proxy if (shExpMatch(host, “.mycompany.com”)) { return “PROXY ://mycompany.com”; } // 3. Send all other traffic through a primary proxy, but fallback to direct if proxy is down return “PROXY primary-proxy.com:8080; DIRECT”; } Use code with caution. Step 3: Host the PAC File

To use the PAC file, it needs to be accessible by your devices. You have two main options:

Host it on a web server: Upload the .pac file to an internal web server (or a secure cloud server) and note the URL (e.g., http://mycompany.com).

Save it locally: If it’s just for your personal use, save the file directly to your local hard drive (e.g., C:\Proxy\proxy.pac on Windows). Step 4: Configure Your Devices

Now you just need to point your operating system or browser to the PAC file URL or local path. 💻 Windows Open Settings and go to Network & Internet > Proxy.

Under the Automatic Proxy Setup section, turn on Use setup script.

Enter the URL of your PAC file (e.g., http://…) or the file path (e.g., file:///C:/Proxy/proxy.pac), and click Save. 🍎 macOS & Safari

Open System Settings (or System Preferences) > Network > Details > Proxies. Check the Automatic Proxy Configuration box. Enter the URL or file path and click OK. 🦊 Mozilla Firefox

Firefox manages its own network settings, which is great for testing: How to Set Up a Proxy in Windows 10 – Dummies