Synology DSM 5.1 – a better wpad.dat for Squid proxy

The latest version of Synology DSM introduces a Squid proxy which allows you to speed up web-browsing within your local LAN due to proxy-caching web fragments. By the looks of it, Synology still needs to improve on the admin functionality, as Squid has quite a few issues. For one, you want to customise your wpad.dat file which is located in “/volume1/web/wpad.dat”:

function FindProxyForURL(url, host)
{
	var local_domain = "*.muffin.lan*";
	var resolved_ip = dnsResolve(host);

	if (isPlainHostName(host)) {return "DIRECT";}
    
	if (shExpMatch(url, local_domain)) {return "DIRECT";}
    
	if (isInNet(resolved_ip, "172.16.0.0", "255.240.0.0") || isInNet(resolved_ip, "127.0.0.0", "255.255.255.0")) {
        	return "DIRECT";
	}

	if (shExpMatch(url,"*mobilebanking.standardbank.co.za*")) {
		return "DIRECT";
	}
        
   return "PROXY 172.16.0.97:3128; DIRECT";
}

In the above example my local domain is “muffin.lan” and my local IP-range is 172.16.0.* and you will want to adjust the highlighted sections. I have also included an exclusion at line 14 (my bank’s iOS application uses HTTPS on a non-standard port and Squid seems to have have some issue with it.

Careful: When the Synology reboots, the wpad.dat file resets to the default and your changes will be lost. This is a PITA and for now I manually copy the config file back.

Synology Squid Proxy crashes when the log file runs full

Another issue where I think Synology has not properly worked through all the issues. The standard configuration writes a 5MB log-file and the proxy crashes during a log-rotate. The work-around is quite simple – edit “/var/packages/ProxyServer/target/etc/squid.logrotate” and change the highlighted lines:

/var/packages/ProxyServer/target/squid/var/logs/access.log{
	size 999M
	...
}

/var/packages/ProxyServer/target/squid/var/logs/cache.log{
	size 999M
	...
}

You would then want to also include the command “/var/packages/ProxyServer/target/bin/squid -k rotate” as a cronjob so that your log-files rotate.

Print Friendly, PDF & Email