Synology usage series 27 – Automatic Proxy Configuration for browser within network

I really had enough maintaining the proxy setting for all browser installed in my home network’s PCs!! I never know this can be done automatically. Until recently I got time doing some search regarding this and wow it is just perfect and simple using diskstation for this task!! Now all I need is to modify a simple javascript and have over 10 browser detect the proxy changes automatically!

This is how things works:

  1. Prepare a javascript file, save it as either WPAD.dat or proxy.pac
  2. Upload the javascript file to the web directory of the disk station.
  3. Setup Apache
  4. Modify the proxy setting of the all browser:

    If you have bind installed on DS, then choose ‘Auto-detect proxy settings in the network

    If you don’t have bind installed, then choose ‘Automatic proxy configuration URL’ and then provide the URL of the javascript file we created at first step.


What is bind?

It is a name server (DNS) we can installed on the diskstation. If we have bind installed on diskstation, we simply need to add a WPAD subdomain and then have the browser detect the URL of the javascript file automatically.

So if you don’t have bind, that’s fine, the only extra step you need to do is to manually input the URL in the browser setting.

Refer to previous article about how to install bind on your diskstation.

Setup bind, the name server

This is optional but a really nice to have.

What we need is to add a type ‘A’ record to the name server

DNS Type: A
Subdomain: WPAD
IP: IP address of the diskstation

So you may add a line to the bind config like below


( is the diskstation ip for example)

Remember to restart the name server.

# /opt/etc/init.d/S09named restart

Of course, all your workstation should use this internal name server as their 1st DNS server to resolve domain name, otherwise it won’t work.

Create a proxy config script

The proxy config script is actually a simple javascript function, I’m not detailing the syntax of javascript, below is my example. For syntax stuffs, google yourself ;p (took forever to explain!!!)

function FindProxyForURL(url,host){

if(isInNet(host, “”, “”)){
return “DIRECT”;
return “PROXY”;

The javascript function above tell the browser use diskstation as http proxy with port 8080. I’ve squid setup in the diskstation listening on port 8080. However, if user is browsing internal site, then tell the browser skip the proxy and use direct connection instead.

If you have bind setup, save the script above to /volume1/web/wpad.dat, else save the script to /volume1/web/proxy.pac

Setup Apache

We need to add a mime type to the Apache for the .pac and .dat file so that the browser agree to download the proxy setting file..

SSH to the diskstation and edit the mime.types file

# vi /usr/syno/apache/conf/mime.types

Add the following lines to the end of the file

application/x-ns-proxy-autoconfig pac dat

Then restart the web server

# /usr/syno/etc/rc.d/ restart
# /usr/syno/etc/rc.d/ restart

Setup browser to look up the proxy config

If you use bind, using firefox as example

Tools / Options / Advanced / Click Network tab / Connection / Click Settings button / Select Auto-detect proxy settings for this network

** This is the default setting of most browser, so this can be skipped for most computer!

If you don’t use bind, using firefox as example

Tools / Options / Advanced / Click Network tab / Connection / Click Settings button / Select Automatic proxy configuration URL:

Input URL to the text box below

Done!! Now all I need is to modify the wpad.dat file for proxy changes and have all browser detect new setting itself 🙂

Note:: browser might cache the proxy config file, so it may take some time for new changes to populate. You might clear the browser cache manually for instant update.

One thought

  1. Hey mate,

    Think i might be doing something wrong tested watching the access.log with wpad and no luck am i right in thinking make the change to

    Have it like so…
    //wpad is for automatic proxy configuration setting, refer to usage series 27 ar

Leave a Reply

Your email address will not be published. Required fields are marked *