26 July 2016

Squid for Ubuntu, because proxies are too much of a hassle

EDIT : Added Authentication methods for dynamic ips


It has been more than a year since I have been using squid to mitigate all the proxy problems that come due to the proxy authentication.

This is the most effective and hassle free way to set proxy in Linux.

Steps:

Note : Replace 'squid' with 'squid3' if you are not using Ubuntu 16.04

1. Install squid

sudo apt-get install squid

2. Edit the squid configuration file.

sudo vim /etc/squid/squid.conf

(for Ubuntu 15.10 and older)

sudo vim /etc/squid3/squid.conf

3. Delete all the contents of that file and replace them with the configuration given below:


Replace 10.0.2.21 with your own ip address/ other ip addresses that you want to access this proxy from.

Change 202.141.80.22 with your Proxy server address.

Change username:password to your proxy username and password.

4. Save the file ( Esc and ":wq" for vim noobs)

5. Restart the squid server.

sudo service squid restart

(for Ubuntu 15.10 and older)

sudo service squid3 restart

6. Edit your Proxy Settings from the network manager.




















7. Open your bash profile.

sudo vim ~/.bashrc

Append the following to the end of the file.

export http_proxy=http://127.0.0.1:3128
export https_proxy=http://127.0.0.1:3128


The above two things should effectively resolve all proxy problems ( Environment Variables inclusive. )

8. Source the bashrc

source ~/.bashrc

And with that you are done!

You have your own personal proxy server!

Say goodbye to proxy problems.


PS - For those of you on the more geeky side of things, what we have done with the above is create our own proxy server that caches another proxy server with authentication.

The proxy server we have made is effectively a non authentication proxy server for the ips in the allowed_ips acl.

If used a bit cleverly it might also help you get around some other big-'time' restrictions ;) .

Use wisely!





Squid with username password authentication

Follow the steps as above.

Afterwords, do the following:

1. Install apache2-utils
sudo apt-get install apache2-utils

2. Make the password file

Replace squid3 with squid if Ubuntu 16.04

sudo touch /etc/squid3/passwd

sudo chmod 755 /etc/squid3/passwd

3. Create a username/password pair


sudo htpasswd /etc/squid3/passwd user1

4. Change the squid.conf file as follows:
5. Restart squid.

sudo service squid3 restart

17 comments:

  1. Is there a way to use torrents in Ubuntu at IITG. I already know for windows but with ubuntu what can you suggest.

    ReplyDelete
    Replies
    1. Wait a while for another blog that I am working on!

      That will solve every restriction that is imposed in an Institute/Workplace internet.

      Delete
    2. Can we cache more than one proxy server?

      Delete
    3. Yes, just add multiple cache peers, it auto switches to the one that's active.

      Delete
  2. Hi
    I am using my own Proxy cache and using same in mobile phone(android)in order to bypass authentication. But in this case communication app like whatsapp, facebook messenger, skype are not working. Others apps are working without any problem. I dont what to use Psiphone and drony dont supports all app. Any suggestion?

    ReplyDelete
    Replies
    1. Whatsapp and messenger don't work because our Institute blocks all ports except 443 and 80.

      That is why you need drony or a VPN like solution what psiphon is.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. Is there any way to allow 443 and 80 port from squid? Is there any vpn for ubuntu which can be used to allow 443 and 80 port too and then using squid we make our proxy.

      Delete
    4. i found something https://ubuntuforums.org/showthread.php?t=896690

      Delete
    5. PLease somebody read it and tell how to work around blocked port
      http://askubuntu.com/questions/107173/is-it-possible-to-ssh-through-port-80

      Delete
  3. how can I bypass download limit restriction(300MB) in squid3??

    ReplyDelete
  4. hey bro,how to connect internet in mobile device?..i have created hostednetwork using cmd COMMANDS..but sometimes when i try to connect my mobile to the hostednetwork (WIFI) it takes much time...but after wifi connected..not a single page opens...& sometimes while connecting...it shows error...FAILED TO OBTAIN IP ADRESS..so please help me

    ReplyDelete
  5. how to use squid proxy using wifi router at hostel room, which ip should i use for it

    ReplyDelete
  6. Thanks for this post, I really appriciate. I have read posts, all are in working condition. and I really like your writing style. Keep it up like.
    tray free proxy liveproxydaily.blogspot.com

    ReplyDelete
  7. The code for squid configuration file is missing, kindly check!

    ReplyDelete
  8. Helpers tend to start out around $10-$12 dollars an hour. Then again that's here, and unions are not prevalent down here so I can't truthfully answer that aspect of your question.

    automated pipe welding

    ReplyDelete
  9. Best Wedding Photographer London in UK | Chris Connorton Photography.
    photographer wedding london

    Are you looking for the very best documentary wedding photographer in London to capture your special day for you? Book now on chris connorton photography.
    best wedding photographer london





    ReplyDelete