Le Blog


KB Olfeo On-Premise
Le 2 juin 2023

How to check if a proxy.pac file is functioning correctly using a pactester.


Check if a proxy.pac file is functioning correctly using a pactester.


proxy.pac files are used to specify the proxy address and port for client workstation browsers. To check whether a specified proxy.pac is functioning correctly, complete the following steps:

You can use the pacparser tool can to check whether a proxy.pac file is functioning correctly.

Pacparser is a library that is used for analysing the automatic configuration of a PAC file proxy. Proxy auto-configuration files are now widely used for the configuration of proxies. Web browsers can use a PAC file to determine the proxy server that is to be used, or whether direct access should be given to a given URL. PAC files are written in JavaScript and can be programmed to return different proxy methods (e.g. « PROXY proxy1: port; DIRECT ») depending on the URL, source IP address, protocol, etc.

The use of PAC files introduces a number of possibilities. PAC files are now a commonly accepted method of managing proxies, with many companies using them in an enterprise environment. PAC files are supported by all of the major web browsers.

Because the proxy.pac mechanism is triggered from the browser and cannot be accessed externally, the only way to determine which proxy the browser will use for a specific URL is to manually check the proxy.pac file. However, manual checking can prove tedious and can result in errors proportional to the size of the file.

The idea behind the pacparser tool is to simplify analysis of PAC files (C and python are currently supported).


Step 1

  1. The first step is to install the tool via the following command in the case of Linux operating systems:

    $ sudo apt-get install libpacparser1 python-pacparser libpacparser-dev

    For Windows and Mac OS X systems, go to the following address:

  2. To install the pacparser C library and pactester in a Windows environment:

    Download and unzip the pacparser -vvv – archive. This will create a pacparser-v.v.v directory.

  3. Copy all .DLL files and the pactester.exe to a location where the system will be able to find them (e.g. to a directory accessible by executable search paths such as C:\Windows) or simply add the pacparser directory to the (PATH) system path.

  4. In pacparser, link libpacparser.a and pacparser.lib respectively with the minGW and Visual Studio compilation tools. To link pacparser to Visual Studio, complete the following steps:

* Python Module

To install the pacparser python module: download and unzip the pacparser – Python25 -vvv – packet. Using the command prompt (cmd), go to the pacparser – Python25 -vvv -win32 directory and run install:

C:\temp > cd pacparser – Python25 – 1.0.5 -win32
C:\temp\pacparser – Python25 – 1.0.5 -win32 > install

If, for some reason, this command fails, simply copy the parparser directory to the python folder: C:\Python25\Lib\site-packages\pacparser.

Step 2

Once the pacparser tool is installed, you can test the proxy.pac configuration file using python:

Note: If the proxy.pac file is hosted on Olfeo, you will need to copy it to the client machine on which pacparser is already installed.

>>> import pacparser
>>> pacparser.init()
>>> pacparser.parse_pac_file(‘examples/wpad.dat’)
>>> pacparser.find_proxy(‘’, ‘’)
>>> pacparser.find_proxy(‘’, ‘’)
>>> pacparser.cleanup()

It is also possible to test the .PAC file using C:

manugarg@hobbiton:~$ cat pactest.c
#include <stdio.h>
#include <pacparser.h>

int main(int argc, char* argv[])
      char *proxy;
      proxy = pacparser_find_proxy(argv[2], argv[3]);
      printf(« %s\n », proxy);

manugarg@hobbiton:~$ gcc -o pactest pactest.c -lpacparser
manugarg@hobbiton:~$ ./pactest wpad.dat


If these conditions are fulfilled, pacparser will return the required proxy and will return the value DIRECT (no proxy).

This tool allows you to perform simple tests on a .PAC file and thereby avoid errors during deployment.