← Back to Blog

How to Configure a PAC File for Proxy: Directing Only Necessary Traffic Without Extra Costs

A PAC file allows for flexible traffic management, directing only the necessary sites through a proxyβ€”without unnecessary costs or loss of speed.

πŸ“…May 15, 2026
```html

If you manage multiple advertising accounts, scrape marketplaces, or work with foreign platforms, you have likely encountered a situation where all traffic goes through a proxy, even though it's only needed for a couple of sites. As a result: speed drops, traffic consumption increases, and the proxy is "burned" faster. A PAC file solves this problem: it allows you to specify exactly which sites go through the proxy and which go directly.

What is a PAC file and why is it needed

PAC stands for Proxy Auto-Configuration β€” automatic proxy configuration. Essentially, it is a small text file with a JavaScript function that determines for each browser or system request whether to route traffic directly or through a proxy server.

It sounds technical, but in practice, it is a very simple tool. You write the rules once β€” and the system applies them automatically. There is no need to manually switch proxies every time or maintain a separate browser for each site.

Who can benefit from this:

  • Arbitrage specialists β€” you run ads on Facebook Ads and TikTok Ads but don’t want all other traffic (email, messengers, work sites) to go through the proxy and slow down your work.
  • SMM specialists β€” you manage 20-50 accounts on Instagram or TikTok, and each profile needs its own proxy only for that specific platform.
  • Marketplace sellers β€” you scrape prices on Wildberries or Ozon, but want only requests to these sites to go through the proxy, not the entire internet.
  • Marketers β€” you check search results and ads from different regions, while all other work is done from your real IP.

The main advantage of a PAC file over regular proxy settings is traffic and resource savings. When all traffic goes through a proxy, you pay for every megabyte, including YouTube, Google Docs, and Windows updates. A PAC file allows you to route through the proxy only what is truly necessary.

πŸ’‘ Important note

PAC files are supported by all modern browsers (Chrome, Firefox, Edge), operating systems (Windows, macOS, Linux), and most anti-detect browsers. This is a standard that has been around for over 25 years.

How a PAC file works: traffic routing logic

Every time a browser or application tries to open a URL, it calls a function from the PAC file and passes two parameters: the URL itself and the host name (domain). The function analyzes this data and returns one of three values:

  • DIRECT β€” connect directly, without a proxy.
  • PROXY host:port β€” use an HTTP proxy with the specified address and port.
  • SOCKS5 host:port β€” use a SOCKS5 proxy.

The function executes instantly β€” before establishing a connection. Users notice no delays. The logic can be as complex as needed: you can route traffic to Facebook through one proxy, to TikTok through another, and let everything else go directly.

Here is a simplified flow of how it works:

  1. You open facebook.com in your browser
  2. The browser calls the PAC file function: "Where to route the request to facebook.com?"
  3. The function checks the list of rules and responds: "Use PROXY 185.10.10.1:8080"
  4. The browser connects to Facebook through the proxy
  5. You open google.com β€” the function responds: "DIRECT"
  6. Google opens directly from your real IP

This approach is called split tunneling β€” traffic separation. It is standard practice in corporate networks and VPNs, but for working with proxies, a PAC file is even better β€” it is easier to configure and does not require additional software installation.

Structure of a PAC file: breaking it down

A PAC file is a regular text file with the extension .pac. Inside it, there is one mandatory JavaScript function named FindProxyForURL. This is the function that the browser calls for each request.

The basic structure looks like this:

function FindProxyForURL(url, host) {

  // Rule 1: if it is localhost β€” always direct
  if (isPlainHostName(host)) {
    return "DIRECT";
  }

  // Rule 2: if the domain is facebook.com β€” through proxy
  if (dnsDomainIs(host, "facebook.com")) {
    return "PROXY 185.10.10.1:8080";
  }

  // Rule 3: all other requests β€” direct
  return "DIRECT";

}

Let’s break down the key built-in functions that you will use most often:

Function What it does Example
dnsDomainIs(host, ".example.com") Checks if the host belongs to the domain Catches facebook.com and all subdomains
shExpMatch(host, "*.example.com") Pattern matching (wildcard) Flexible filtering by domain mask
isInNet(host, "10.0.0.0", "255.0.0.0") Checks if it belongs to an IP subnet For filtering by IP ranges
isPlainHostName(host) Checks if the host is a local name localhost, printer, nas β€” direct
localHostOrDomainIs(host, "...") Checks local host or domain For internal network exceptions

An important nuance: the function processes rules top to bottom and stops at the first match. Therefore, the order of rules matters β€” place more specific conditions first, and a general default rule at the end.

Ready-made PAC file examples for real tasks

Below are four practical templates for specific tasks. Copy the one you need, replace the proxy address and port with your data β€” and the file is ready to use.

Template 1: Only Facebook and Instagram through proxy (for arbitrage specialists)

function FindProxyForURL(url, host) {

  // Local addresses β€” always direct
  if (isPlainHostName(host) || 
      shExpMatch(host, "*.local") ||
      host === "127.0.0.1") {
    return "DIRECT";
  }

  // Facebook and all its subdomains β€” through proxy
  if (dnsDomainIs(host, "facebook.com") ||
      dnsDomainIs(host, "fbcdn.net") ||
      dnsDomainIs(host, "fb.com")) {
    return "PROXY 185.10.10.1:8080";
  }

  // Instagram β€” through the same proxy
  if (dnsDomainIs(host, "instagram.com") ||
      dnsDomainIs(host, "cdninstagram.com")) {
    return "PROXY 185.10.10.1:8080";
  }

  // Everything else β€” direct
  return "DIRECT";

}

Template 2: Different proxies for different platforms (for SMM agencies)

function FindProxyForURL(url, host) {

  if (isPlainHostName(host)) {
    return "DIRECT";
  }

  // Instagram β€” through residential proxy #1
  if (dnsDomainIs(host, "instagram.com") ||
      dnsDomainIs(host, "cdninstagram.com")) {
    return "PROXY 91.200.10.5:3128";
  }

  // TikTok β€” through residential proxy #2
  if (dnsDomainIs(host, "tiktok.com") ||
      dnsDomainIs(host, "tiktokcdn.com") ||
      dnsDomainIs(host, "musical.ly")) {
    return "PROXY 91.200.10.6:3128";
  }

  // VK β€” through a separate proxy
  if (dnsDomainIs(host, "vk.com") ||
      dnsDomainIs(host, "vk.me") ||
      dnsDomainIs(host, "userapi.com")) {
    return "PROXY 91.200.10.7:3128";
  }

  return "DIRECT";

}

Template 3: Scraping Wildberries and Ozon (for sellers)

function FindProxyForURL(url, host) {

  if (isPlainHostName(host)) {
    return "DIRECT";
  }

  // Wildberries β€” through proxy (price scraping)
  if (dnsDomainIs(host, "wildberries.ru") ||
      dnsDomainIs(host, "wbstatic.net") ||
      dnsDomainIs(host, "wb.ru")) {
    return "PROXY 45.130.10.20:8080";
  }

  // Ozon β€” through proxy
  if (dnsDomainIs(host, "ozon.ru") ||
      dnsDomainIs(host, "ozonusercontent.com")) {
    return "PROXY 45.130.10.20:8080";
  }

  // Avito β€” through proxy
  if (dnsDomainIs(host, "avito.ru") ||
      dnsDomainIs(host, "avito.st")) {
    return "PROXY 45.130.10.20:8080";
  }

  return "DIRECT";

}

Template 4: SOCKS5 proxy with backup HTTP (fault tolerance)

function FindProxyForURL(url, host) {

  if (isPlainHostName(host)) {
    return "DIRECT";
  }

  // Target sites β€” SOCKS5 primary, HTTP backup
  if (dnsDomainIs(host, "facebook.com") ||
      dnsDomainIs(host, "instagram.com") ||
      dnsDomainIs(host, "tiktok.com")) {
    // If SOCKS5 is unavailable β€” automatically switch to HTTP
    return "SOCKS5 185.10.10.1:1080; PROXY 185.10.10.1:8080; DIRECT";
  }

  return "DIRECT";

}

πŸ’‘ About backup proxies

The line "SOCKS5 ...; PROXY ...; DIRECT" is a chain of backups. If the first proxy is unavailable, the browser will automatically try the second, then the direct connection. This is very convenient for critical tasks where downtime cannot be tolerated.

How to connect a PAC file in a browser and system

There are two ways to connect a PAC file: through a local file on your computer or via URL (if the file is hosted on a server). For most tasks, a local file is sufficient.

Step 1: Create a PAC file

Open any text editor (Notepad, Notepad++, VS Code) and paste the code from the templates above. Save the file with the extension .pac, for example: proxy_rules.pac. Recommended storage location: C:\proxy\proxy_rules.pac (Windows) or /Users/username/proxy/proxy_rules.pac (macOS).

Step 2: Connecting in Windows 10/11

  1. Open Settings β†’ Network & Internet β†’ Proxy
  2. In the "Use setup script" section, toggle the switch to On
  3. In the "Script address" field, enter the file path in the format: file:///C:/proxy/proxy_rules.pac
  4. Click Save
  5. Restart the browser

Step 3: Connecting in macOS

  1. Open System Preferences β†’ Network
  2. Select the active network connection (Wi-Fi or Ethernet) and click Advanced
  3. Go to the Proxies tab
  4. Check the box for Automatic proxy configuration
  5. In the URL field, enter: file:///Users/username/proxy/proxy_rules.pac
  6. Click OK β†’ Apply

Step 4: Connecting in Google Chrome (separate from the system)

Chrome uses system proxy settings, but you can launch it with a separate PAC file via command line parameters. This is convenient if you want only Chrome to work through the PAC, while other applications do not.

Create a Chrome shortcut and add to the end of the "Target" field:

--proxy-pac-url="file:///C:/proxy/proxy_rules.pac"

Step 5: Connecting in Firefox

  1. Open Settings β†’ General β†’ Network Settings β†’ Settings
  2. Select Automatic proxy configuration URL
  3. Enter the path: file:///C:/proxy/proxy_rules.pac
  4. Click OK

PAC file in anti-detect browsers: Dolphin, AdsPower, GoLogin

For arbitrage specialists and SMM professionals working with anti-detect browsers, a PAC file opens up additional opportunities. Instead of assigning one proxy for the entire profile, you can set up flexible routing directly within the browser profile.

Dolphin Anty

In Dolphin Anty, the PAC file is connected at the profile level. When creating or editing a profile in the Proxy section, select the type PAC-script and specify the URL or path to the file. This allows one profile to use different proxies for different sites β€” for example, Facebook through a mobile proxy, while everything else goes directly.

Practical scenario: you have 10 Facebook ad accounts. For each profile in Dolphin, you connect a PAC file that routes only Facebook and Instagram domains through the proxy. The rest of the traffic (extension downloads, updates) goes directly β€” this saves proxy traffic by up to 70%.

AdsPower

In AdsPower, when setting up a profile in the Proxy Settings section, there is a field for entering the PAC URL. Specify the address of your PAC file β€” if it is local, host it on a simple local HTTP server (for example, via Python: python -m http.server 8000) and specify the address http://localhost:8000/proxy_rules.pac.

GoLogin

GoLogin supports PAC files through the Proxy URL field in the profile settings. The syntax is similar β€” you specify the full URL to the file. GoLogin also allows you to save proxy settings templates and apply them en masse to multiple profiles at once, which is convenient when working with a large number of accounts.

Multilogin and Octo Browser

Both browsers support PAC configuration via URL. In Multilogin, this is configured in the Profile β†’ Proxy β†’ Custom proxy section. In Octo Browser β€” similarly, in the profile settings, select the proxy type PAC and specify the link to the file.

πŸ”§ Life hack for anti-detect browsers

Host the PAC file on a free hosting service (GitHub Pages, Pastebin RAW, Cloudflare Workers) β€” then you won’t need a local server, and the file will be accessible from any profile and any device. Plus, you can update the rules in one place, and the changes will apply to all profiles at once.

Which type of proxy to choose for PAC configuration

A PAC file works with any type of proxy, but different options are suitable for different tasks. Here is a comparative table to help you make a choice:

Proxy Type Best for Protocols in PAC Speed
Residential Facebook Ads, Instagram, TikTok β€” social networks with strict anti-fraud protection PROXY, SOCKS5 Average
Mobile Account farming, working with mobile versions of applications PROXY, SOCKS5 Average
Datacenter Scraping marketplaces, price monitoring, SEO tasks PROXY, SOCKS5 High

For working with Facebook Ads and Instagram through PAC configuration, arbitrage specialists most often choose residential proxies β€” they have real IPs of home users and raise fewer suspicions from the platform algorithms.

If you manage accounts on Instagram or TikTok from mobile devices or through mobile profiles in anti-detect browsers, consider mobile proxies β€” they operate through real mobile networks of carriers and provide the cleanest traffic for these platforms.

For scraping tasks on Wildberries, Ozon, or Avito, where speed and the number of requests are important, datacenter proxies are the optimal choice β€” they are faster and allow for a large number of requests in a short time.

Setting up authentication in a PAC file

If your proxy requires a username and password, you do not need to specify them in the PAC file β€” this is unsafe as the file can be read. Authentication is handled separately by the browser: upon the first connection, it will request credentials and save them. Alternatively, use proxies with IP authorization β€” then a username/password is not needed at all.

Common errors and how to fix them

When setting up a PAC file, most problems are related to several typical errors. Let’s break down each one with solutions.

Error 1: PAC file is not applied

Symptom: you specified the file path, but traffic still goes directly or through old settings.

Causes and solutions:

  • Incorrect file path. Check the format: on Windows it should be file:///C:/path/file.pac (three slashes after file:)
  • The browser has cached old settings. Completely close the browser and reopen it.
  • In Windows, group policy may interfere. Check through gpedit.msc β†’ Computer Configuration β†’ Administrative Templates β†’ Windows Components β†’ Internet Explorer

Error 2: All traffic goes through the proxy, not just the necessary one

Symptom: speed has dropped, the entire internet is slow.

Cause: at the end of the function, there is return "PROXY ..." instead of return "DIRECT".

Solution: ensure that the last line of the function is return "DIRECT"; This is the default rule for everything that did not meet previous conditions.

Error 3: Subdomains do not fall under the rule

Symptom: the rule for facebook.com works, but static.facebook.com or m.facebook.com does not.

Cause: the function dnsDomainIs checks for an exact match of the domain and all its subdomains, but only if you specified the domain with a dot at the beginning.

Solution: use dnsDomainIs(host, "facebook.com") β€” this function automatically captures all subdomains. Alternatively, add separate lines for each subdomain.

Error 4: Syntax error in JavaScript

Symptom: the PAC file does not work at all, the browser ignores it.

Solution: check the file in an online tool like PAC File Debugger (search in Google) or paste the code into the browser console (F12 β†’ Console) β€” JavaScript errors will be visible immediately. Most often, the problem is a missing bracket or semicolon.

Error 5: PAC file does not work with HTTPS sites

Symptom: HTTP sites open through the proxy, HTTPS does not.

Cause: for HTTPS, the browser establishes a tunnel via the CONNECT method. Some HTTP proxies do not support CONNECT.

Solution: use SOCKS5 proxies instead of HTTP β€” it supports both types of connections. In the PAC file, replace PROXY with SOCKS5.

Checklist for checking the PAC file

  • βœ… The function is exactly named FindProxyForURL (case-sensitive)
  • βœ… The function takes two parameters: url and host
  • βœ… All curly braces are closed
  • βœ… At the end of the function, there is return "DIRECT";
  • βœ… The proxy address is in the format IP:PORT without spaces
  • βœ… The file is saved in UTF-8 encoding
  • βœ… The file path in the settings starts with file:///
  • βœ… The browser has been restarted after changes

Conclusion and recommendations

A PAC file is one of the most underrated tools for those who work with proxies professionally. It solves several problems at once: saves proxy traffic, maintains speed for the rest of the internet, and allows flexible routing management without manually switching settings.

For arbitrage specialists, a PAC file in conjunction with an anti-detect browser (Dolphin Anty, AdsPower, GoLogin) allows you to configure it so that only Facebook Ads or TikTok Ads traffic goes through the proxy β€” and not a byte more. For SMM specialists β€” different proxies for Instagram, TikTok, and VK within one system. For marketplace sellers β€” targeted scraping of Wildberries and Ozon without unnecessary load.

The main thing to remember: a PAC file is just a text file with a few lines of code. There is no need to be afraid of it. Take one of the ready-made templates from this article, substitute your proxy data β€” and in 10 minutes you will have flexible traffic routing set up.

If you plan to work with Facebook Ads, Instagram, or TikTok through PAC configuration, we recommend using residential proxies β€” they provide the highest level of trust from the platforms and minimal risk of blocks with proper routing setup through the PAC file.

```