Questions tagged [pac]

A proxy auto config file (PAC) is used by a web browser (or other agent) to choose the proxy server to be used using the specified URL as a criteria for the selection.

A proxy auto-config (PAC) file defines how web browsers and other user agents can automatically choose the appropriate proxy server (access method) for fetching a given URL.

A PAC file contains a JavaScript function FindProxyForURL(url, host). This function returns a string with one or more access method specifications that cause the user agent to use a particular proxy server, or to connect directly.

This is an example of a very simple PAC file:

function FindProxyForURL(url, host) {
    return "PROXY proxy.example.com:8080; DIRECT";
}

this PAC file instructs the browser to retrieve all pages through the proxy on port 8080 of the server proxy.example.com. Should this proxy fail to respond, the browser tries to contacts the Web-site directly, without using a proxy.

A more complicated PAC file can be like this:

function FindProxyForURL(url, host) {
    // our local URLs from the domains below example.com don't need a proxy:
    if (shExpMatch(host, "*.example.com")) {
        return "DIRECT";
    }

    // URLs within this network are accessed through
    // port 8080 on fastproxy.example.com:
    if (isInNet(host, "10.0.0.0", "255.255.248.0")) {
        return "PROXY fastproxy.example.com:8080";
    }

    // All other requests go through port 8080 of proxy.example.com.
    // should that fail to respond, go directly to the WWW:
    return "PROXY proxy.example.com:8080; DIRECT";
}
150 questions
1
vote
0 answers

How to use script for auto switching of Internet proxy in Windows 10?

I am writing a javascript code to auto switch the proxy settings based on the IP of the network on which my system gets plugged into. Like when I am into the LAN of my company, it'll automatically use company's proxy, if on Client's network then use…
aiman
  • 1,049
  • 19
  • 57
1
vote
1 answer

Java - Status 401 - PAC Proxy authentication for JSoup

I'm trying to use Jsoup to gather elements from a webpage, however I am behind a PAC Proxy. When I try to access a website using Jsoup I get a code status 401 Authentication error. It seems issue is with proxy. I have installed a library called…
1
vote
0 answers

Automatic PAC detection for smtplib

I'm trying to send an email with a Python 3.5 script, from a laptop that is connected to the internet through a PAC file. Is there a way of using PyPAC for this? With requests, this already works like a charm. from pypac import PACSession session =…
Nicolas Berthier
  • 459
  • 1
  • 8
  • 17
1
vote
0 answers

Block chrome network requests until extension is initialized

I am working on proxy extension for chrome browser. My extension sets proxy config of the browser using: chrome.proxy.settings.set({ value: config, scope: 'regular', }); Where config uses fixed_servers mode. Proxy servers require…
1
vote
1 answer

How to fix pac file not recognized for python selenium test?

For reasons I am not able to explain here in a short manner, I want to use a pac file for a firefox test (python-selenium) to coordinate the used proxy for various types of requests. Here is the pac file I am using: function FindProxyForURL(url,…
Alex
  • 41,580
  • 88
  • 260
  • 469
1
vote
0 answers

How to set the length of the low band-pass filter (seconds) when filtering EEG?

When I used the neurodsp model to compute the Phase-Amplitude coupling of EEG, I found there are four parameters need to set carefully, respectively N_seconds_lo, N_seconds_hi, N_cycles_pha and N_cycles_amp. The results were very different when the…
Mindy
  • 175
  • 1
  • 1
  • 8
1
vote
1 answer

How to tell macos proxy settings that the proxy is HTTPS server instead of HTTP?

I set up a HTTPS proxy server and use macos system proxy settings to set to localhost:8080. However the system seems keeping sending HTTP requests to the proxy and the TLS throws errors. I guess that Macos by default forward original request with a…
PeiSong
  • 871
  • 1
  • 7
  • 12
1
vote
0 answers

Is PAC file compiled or interpreted?

Suppose I have two exceptions in the PAC file as follows: if (shExpMatch("host",abc.xyz.com)) { return "PROXY 165.225.123.124:80"; } /* . . . */ if (shExpMatch("host",*.xyz.com)) { return "DIRECT"; } Now as per the first exception in the PAC…
Techievent.in
  • 75
  • 1
  • 9
1
vote
1 answer

Using urllib.request returns Proxy Auto-Config file

I am using Martin Konecny's code from here to query an http site, from behind my corporate firewall: The code is this: import urllib.request req = urllib.request.Request( 'http://www.espncricinfo.com/', data=None, headers={ …
Soham
  • 863
  • 2
  • 19
  • 35
1
vote
1 answer

Can PAC file contain query string?

I have a PAC file on my server, and it looks like this: function FindProxyForURL(url, host) { var a = "55.15.75.65:8180"; var b = "DIRECT"; var nolst = Array( "*.css", "*.js", "*/corpgrp/*" ); for(var…
Ibrahim D.
  • 318
  • 4
  • 17
1
vote
1 answer

how to fix this pac file javascript code with regex

I have some strings. 127.0.0.1:46977/safekids/permission_denied.html domain1.com/denied/permission_safekid.html domain2.eu/pkb/1144/niche/denied/permission_safekid.html 192.168.1.6:46977/14/asp/var/denied/permission_kid.html And I have a…
1
vote
0 answers

PAC file on Android Devices

I have a setup with my Android device on VPN. I also have a pac file so that all internal traffic goes direct and all Internet traffic is routed to the proxy. For some reason, when I try to go to an Internet page (e.g. bbc.com) it tries to resolve…
1
vote
1 answer

Setting proxy as System properties not working

I'm trying to set a proxy to use in my application. When I try to set it as a system property: Proxy proxy = ... // code to retrieve proxy from .pac file InetSocketAddress addr = (InetSocketAddress)…
lucasdc
  • 1,032
  • 2
  • 20
  • 42
1
vote
0 answers

XMLHttpRequest in PAC file?

It is possible to use XMLHttpRequest in firefox PAC file? I write a little JS script that get proxy from one site api, but when I tried to use it I get error: XMLHttpRequest is not defined
ANDREA
  • 11
  • 2
1
vote
1 answer

How does the browser determines if proxy is 'not available' when using PAC file

I have the following PAC file code: function FindProxyForURL(url, host) { return "PROXY proxy1:8080" + "PROXY proxy2:8080; "; }; According to Java this should work as follows (https://docs.oracle.com/cd/E19575-01/821-0053/adyrr/index.html): In…