User Tools

Site Tools


howto:firefox-proxy

This is an old revision of the document!


Firefox Proxy

To use a proxy for specific sites only, the easiest option is to create a pac file and configure Firefox to use it as automatic proxy configuration.

Example pac file:

function FindProxyForURL(url, host) {
    if (dnsDomainIs(host, "example.com")) {
        return "HTTP 192.168.0.1:8888";
    }
}

Possible option to identify network to only use proxy if in home network or private ip range:

function FindProxyForURL(url, host) {
    var myIP = myIpAddress();

    // Detect by IP range (example: 192.168.1.x) or DNS suffix (example: home.lan)
    if (
        isInNet(myIP, "192.168.1.0", "255.255.255.0") ||
        dnsDomainIs(host, ".home.lan")
    ) {
        return "PROXY proxy.example.com:8080";
    }

    // Otherwise, no proxy
    return "DIRECT";
}

Store this somewhere and go to about:preferences → general → Network settings (very bottom) → settings, select “Automatic proxy configuration URL” and enter the path to the pac file in the file protocol notation, e.g.:

file:///home/user/.mozilla/firefox/ffox.default/custom_proxies.pac

After making changes to the file, go back to the Firefox proxy configuration URL settings and click reload.

Further info:
Mozilla Dev

howto/firefox-proxy.1755178807.txt.gz · Last modified: by Wulf Rajek