I decided to do a bit of checking on the proxy.pac file we were using. I grepped through our Apache access log files to pull out all of the IP addresses accessing the file over the year:
zgrep "proxy.pac" ./2013-??-??.access_log.gz | awk '{print $1}' | awk -F ":" '{print $2}' | sort | uniq > ip_addresses.txt
Armed with the list of IP addresses I next fired up pactester.
Pactester
Pactester is available from Google Code
Simple usage:
/usr/bin/pactester -p /var/www/htdocs/proxy.pac -u http://www.bbc.co.uk -c 192.168.196.165
The output of which could be:
PROXY server1.domain.uk:8080; PROXY server2.domain.uk:8080
So to test all my IP addresses I feed the IP addresses to pactester and I can grep for the output I am looking for e.g. DIRECT connections:
#!/bin/bash
#for IP in `zgrep "proxy.pac" ./2013-??-??.access_log.gz | awk '{print $1}' | awk -F ":" '{print $2}' | sort | uniq`; do
for IP in `cat /home/jonny/ip_addresses.txt`; do
COUNT=`/usr/bin/pactester -p /var/www/htdocs/proxy.pac -u http://www.bbc.co.uk -c $IP | grep DIRECT | wc -l`
if [ $COUNT -gt 0 ]; then
echo $IP" DIRECT"
fi
done