Friday, December 23, 2016

Proxy script for blocking websites

This proxy script can be used in Windows to either block individual websites (blacklisting) or allow only specific websites (whitelisting), this example is for whitelisting:


function FindProxyForURL(url, host) {
 // Bypass the proxy for *.blogger.com
 if (dnsDomainIs(host, ".blogger.com")) {
               return "DIRECT";
 }
 return "PROXY http://127.0.0.1:18080";
 } // End of function


This is saved as a .pac file. In Control Panel, in the Internet Options, find the Connections tab, LAN settings. Uncheck “Automatically Detect Settings”. Click to check the box named “Use automatic configuration script”.

In the address field, type the location of .pac file as the following:
File://C:/Path/script.pac
 
More here.