While i long-staying in Thailand, i have some problems with playing streaming data like audio / video from vk.com. I don’t want to send all my traffic via any VPS/Proxy because i will have more problems with big services like google. They have geo CDN and i have beautifful access speed and ping to them (ping about 10 msec). Bug sometimes i want to listen music or play any movie.

And i fixed this problem for me. I used my own proxy server for only some url masks, not for whole traffic.

I used things to do it:

  1. Good bandwidth server. I used fresh clean VDS on my dedicated server.
  2. Proxy server. I used Squid.
  3. Web Server for placing configuration file


At debian linux system you can install simple install squid like a charm.

apt-get install squid3

After installation yo will get working squid which denies any requests throught it. We need to add some configuration to allow us go required site.

If you want add authorization to your squid and allow only authorized users access, you can use this configuration.

auth_param basic children 5
auth_param basic realm Web Proxy
auth_param basic program /usr/lib/squid3/ncsa_auth /etc/squid3/squid_user
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
acl authed proxy_auth REQUIRED
acl domaines_allow dstdomain .vk.com .vk.me
http_access allow authed domaines_allow

And you need to create users htpass file with command.

root@vds107:/etc/squid3# htpasswd /etc/squid3/squid_user vk
New password: 
Re-type new password: 
Adding password for user vk

If you want allow anybody access configured domains without authorization, you can use this configuration.

acl domaines_allow dstdomain .vk.com .vk.me
http_access allow domaines_allow

After configuration of course we need to restart squid proxy server by command

root@vds107:/etc/squid3# service  squid3 restart
[ ok ] Restarting Squid HTTP Proxy 3.x: squid3[....]  Waiting.....................done.

And check for listening ports.

root@vds107:/etc/squid3# netstat -ln | grep 3128
tcp6       0      0 :::3128                 :::*                    LISTEN     

Ok, all seems to be good. We can go next step.

Browser configuration and Proxy-PAC

I need only 2 domains to be redirected to proxy and i made simple PAC file for it.

function FindProxyForURL(url, host) {
    if ((shExpMatch(host, "*.vk.com") || shExpMatch(host, "*.vk.me")) && url.indexOf('.mp3') != -1)
        return "PROXY ip.address:33128";
    return "DIRECT";

After creating, we need to put this file on any accessible web server. For this purposes i used locally installed nginx. And i got working proxy.pac file by url Important: if you make extension of file other then *.pac, you can have some hours of ‘funny bugfixing’, because browsers require extension *.pac.

Ok, now we can place setup our browser to use this file. Take a look into picture please.

Firefox proxy configuration

Now we finished configuration. All must work like a charm. You can check your traffic in firebug (or any other browser debugger). Take a look into my traffic.


For me all working great!

Tagged with:

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>