Extension Proxy API: Modes, PAC Scripts, and Bypass Rules
How browser extensions set proxy modes, fixed servers, PAC scripts, and bypass lists, and how that differs from VPN provider APIs.
This page summarises Chrome extension proxy API documentation (also published for Manifest V2) and related material on VPN provider extensions, Open Network Configuration (ONC) proxy fields, and PAC file practices from Cloudflare. It is for developers who need extensions to read or change how the browser sends HTTP, HTTPS, and FTP traffic through proxies—not for end-user OS proxy dialogs alone.
chrome.proxy API: what extension proxy settings control
Section titled “chrome.proxy API: what extension proxy settings control”The chrome.proxy API (and the cross-browser browser.proxy namespace in the same reference) lets an extension manage the browser’s proxy settings. Those settings ride on the same ChromeSetting pattern as other extension types APIs: you read and write a single ProxyConfig value through proxy.settings.
Use the chrome.proxy API to manage Chrome’s proxy settings. This API relies on the ChromeSetting prototype of the type API for getting and setting the proxy configuration.
— Chrome, proxy API
A complete configuration is a proxy.ProxyConfig object. Depending on the active mode, that object may hold proxy.ProxyRules (manual / fixed servers) or proxy.PacScript (PAC URL or inline script). Nothing else is valid inside ProxyConfig for a given mode—the documentation states that each mode allows no further parameters beyond what that mode defines.
When to use chrome.proxy versus a VPN extension
Section titled “When to use chrome.proxy versus a VPN extension”Use chrome.proxy when you only need to steer URL-scheme traffic (HTTP, HTTPS, FTP) through a proxy or PAC decision. Use chrome.vpnProvider when you implement a full VPN client on ChromeOS: the platform hands you a VPN session, expects tunnel parameters, and exchanges IP packets with your extension.
Use the chrome.vpnProvider API to implement a VPN client.
— Chrome, vpnProvider API
Those APIs solve different layers. Proxy settings affect how the browser (and other consumers of the same setting) resolve PROXY vs DIRECT for web-like schemes. A VPN provider owns a virtual interface, split-tunnel lists in CIDR form, and packet I/O for the session. Do not assume that setting fixed_servers replaces a VPN tunnel or vice versa.
ProxyConfig mode: direct, PAC, fixed servers, and system
Section titled “ProxyConfig mode: direct, PAC, fixed servers, and system”The mode field on ProxyConfig is the first decision point. It defines whether Chrome uses no proxy, WPAD, a PAC script, fixed rules, or the operating system’s proxy.
A ProxyConfig object’s mode attribute determines the overall behavior of Chrome with regards to proxy usage.
— Chrome, proxy API
| Mode value | What it does | Extra fields allowed on ProxyConfig |
|---|---|---|
direct |
All connections go out directly; no proxy. | None |
auto_detect |
WPAD: fetch PAC from http://wpad/wpad.dat. |
None |
pac_script |
PAC from pacScript.url or inline pacScript.data. |
pacScript only |
fixed_servers |
Manual rules in rules (ProxyRules). |
rules only |
system |
Use OS proxy settings. | None |
pac_script mode: URL, inline data, and mandatory PAC
Section titled “pac_script mode: URL, inline data, and mandatory PAC”In pac_script mode, exactly one of PacScript.url or PacScript.data should be set. Optional PacScript.mandatory (default false) controls failure behavior: when true, an invalid PAC script blocks the network stack from falling back to direct connections.
When you author PAC logic (whether hosted or inline), Cloudflare’s proxy-endpoint guidance recommends handling plain hostnames before other rules so internal NetBIOS-style names bypass the proxy:
NetBIOS names (hostnames without periods) are typically internal and should bypass the proxy. Check for these first:
if (isPlainHostName(host)) return "DIRECT";— Cloudflare, PAC file best practices
The same guide notes that large streaming hosts may work better with DIRECT, which you can mirror in extension-owned PAC data strings when policy allows.
fixed_servers mode: ProxyRules and ProxyServer
Section titled “fixed_servers mode: ProxyRules and ProxyServer”For fixed_servers, populate rules with either singleProxy or a subset of proxyForHttp, proxyForHttps, proxyForFtp, and fallbackProxy.
With singleProxy, HTTP, HTTPS, and FTP share one ProxyServer; other traffic goes direct. With per-scheme fields, each listed scheme uses its server; unmatched schemes use fallbackProxy if present, otherwise direct.
Each ProxyServer needs host (ASCII / Punycode hostnames; IDNA is not supported per docs). Optional scheme defaults to http for the connection to the proxy itself. Supported schemes include http, https, quic, socks4, and socks5. If port is omitted, defaults are: http 80, https 443, socks4/socks5 1080.
Example from the official reference—SOCKS5 for HTTP only, with a bypass host:
var config = { mode: "fixed_servers", rules: { proxyForHttp: { scheme: "socks5", host: "1.2.3.4" }, bypassList: ["foobar.com"] }};chrome.proxy.settings.set( {value: config, scope: 'regular'}, function() {});(Equivalent sample appears in both MV3 and MV2 proxy pages.)
bypassList: how to exclude hosts from the proxy
Section titled “bypassList: how to exclude hosts from the proxy”bypassList is a string array on ProxyRules. Entries can match host patterns, IP literals, CIDR ranges, or the special token <local> for simple hostnames (no dots, not an IP literal—e.g. localhost).
Pattern matching nuances matter in production:
- A leading
.on a pattern is treated as*.(e.g..foobar.commatcheswww.foobar.combut not apexfoobar.com). foobar.commatches only that exact host, notwww.foobar.com.*foobar.commatches both apex and subdomains and also suffix matches likefoofoobar.com.
For IPv6 literals, canonicalization is applied internally ([0:0:0::1] matches [::1]). CIDR entries such as 192.168.1.1/16 exclude entire ranges.
Misconfigured bypass lists are a common reason “only some users” still hit the proxy—always cross-check patterns against the table in the proxy API bypass list section.
proxy.settings: scope, effective config, and incognito
Section titled “proxy.settings: scope, effective config, and incognito”Proxy settings are exposed as chrome.proxy.settings with a ProxyConfig value. Calls use the ChromeSetting set/get shape: for example { value: config, scope: 'regular' } on set, and { incognito: false } on get.
Important behaviors from the reference examples:
- Settings applied with
scope: 'regular'also apply to incognito windows, which inherit from regular windows. - The effective configuration may come from another extension or enterprise policy—not only from your last
setcall. - Objects returned from
get()are not identical to what you passed toset(); for instance,get()may addrules.proxyForHttp.porteven when you omittedporton set.
To inspect effective settings:
chrome.proxy.settings.get( {'incognito': false}, function(config) { console.log(JSON.stringify(config)); });See the proxy API examples and Types API cross-links there for policy precedence details.
ChromeOS ONC and enterprise proxy types (related configuration)
Section titled “ChromeOS ONC and enterprise proxy types (related configuration)”On ChromeOS, managed networks describe proxy behavior in ONC ProxySettings, separate from but conceptually parallel to extension ProxyConfig. ONC ProxySettings.Type may be Direct, Manual, PAC, or WPAD, with Manual breaking out HTTPProxy, SecureHTTPProxy, FTPProxy, SOCKS, and ExcludeDomains. Per-network WebProxyAutoDiscoveryUrl can also surface WPAD URLs from DHCP in IPConfigProperties.
Extensions that must align with device policy should treat ONC as the administrator’s view of the same problem space—fixed manual proxies, PAC URLs, and exclusions—while chrome.proxy remains the programmatic surface for extensions permitted to change the browser proxy ChromeSetting. Full property lists live under chrome.networking.onc.
vpnProvider on ChromeOS: sessions, split tunnel, and platform messages
Section titled “vpnProvider on ChromeOS: sessions, split tunnel, and platform messages”If the goal is a user-selectable VPN in ChromeOS settings—not merely a web proxy—follow the vpnProvider workflow:
createConfig()for a persistent UI entry.- Listen for
onPlatformMessage,onPacketReceived,onConfigRemoved. - On platform message
"connected", start the client,setParameters(), thennotifyConnectionStateChanged({ state: "connected" }). - Use
sendPacket()/onPacketReceivedfor tunneled IP traffic until"disconnected".
Session parameters include address (IPv4 CIDR only), dnsServers, optional domainSearch, mtu (default 1500), and split-tunnel lists:
inclusionList— CIDR blocks sent through the tunnel; default sends nothing through the tunnel until you add routes;0.0.0.0/0sends all user traffic.exclusionList— CIDR blocks kept off the tunnel (e.g. reach VPN server public IPs).
When multiple rules match a destination, longest prefix wins; duplicate CIDRs between inclusion and exclusion are deduplicated with undefined survivor semantics—avoid relying on duplicate entries.
Platform messages include connected, disconnected, error, linkDown, linkUp, linkChanged, suspend, and resume. With reconnect: true (Chrome 51+), the extension should react to link and power events; if false, the system disconnects the VPN on topology changes and the user must reconnect manually.
Third-party VPN entries tie to ExtensionID in ONC ThirdPartyVPNProperties, linking UI network objects to the providing extension—see vpnProvider and ONC VPN properties.
Common mistakes when implementing extension proxy or VPN behavior
Section titled “Common mistakes when implementing extension proxy or VPN behavior”- Mixing modes and extra fields — Supplying
ruleswhilemodeispac_script(or other illegal combinations) does not match the documented contract; each mode allows only its paired object. - Wrong bypass pattern — Using
foobar.comwhen you meant all subdomains; use*.foobar.comor understand leading-dot semantics. - Assuming your
setwins — Alwaysget()effective settings; another extension or policy may override you. - Treating proxy as VPN —
fixed_serversdoes not create a tunnel interface; packet capture still needsvpnProvideron ChromeOS (withvpnProviderpermission). - PAC mandatory flag — Setting
mandatory: truewithout rigorous PAC testing can hard-fail connectivity on script errors. - Ignoring
get()shape — Code that deep-comparessetpayloads toget()callbacks may break on implicit default ports.
How to check this on your site
Section titled “How to check this on your site”-
In your extension’s service worker or background page, call
chrome.proxy.settings.get({ incognito: false }, …)and log the effectiveProxyConfig, matching the pattern in the proxy API examples. -
Apply a test
fixed_serversorpac_scriptconfiguration withscope: 'regular', load a known HTTP URL, and confirm traffic behavior matches yourrulesor PACFindProxyForURLreturn values. -
Validate each
bypassListentry against the pattern table in the proxy API using hosts you control (apex, subdomain, and IP literal cases). -
For ChromeOS VPN work, step through connect/disconnect once and confirm
notifyConnectionStateChangedreportsconnectedonly aftersetParameterssucceeds, per vpnProvider usage. -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about, and we will correct or clarify it.