Friday, May 30, 2008

How to setup squid to forward all request to another authenticated proxy

Basically, authenticated proxy are real pain to deal with 'cause every other program seems to take it for granted that it has free acess to net. At the most, you might be lucky if the program supports proxy, without authentication that is.

However, if you are on Linux, don't worry. You can easily setup Squid as a local proxy which would then forward all requests to the authenticated proxy.

From Wikipedia:

Squid is a proxy server and web cache daemon. It has a wide variety of uses, from speeding up a web server by caching repeated requests, to caching web, DNS and other computer network lookups for a group of people sharing network resources, to aiding security by filtering traffic. Although primarily used for HTTP and FTP, Squid includes limited support for several other protocols including TLS, SSL, Internet Gopher and HTTPS. The development version of Squid (3.1) includes IPv6 and ICAP support.


So its basically a swiss army knife for web management, but we will deal with only very basic stuff.

First of all, we need to install Squid itself. Since I use Ubuntu, it is as easy as typing

sudo apt-get install squid

This should install squid and get it running. You can achive the same on Fedora with yum or build from source if you need it.

Next, we have to configure squid to forward our requests to Proxy server.
For this, open the file /etc/squid/squid.conf with your favorite text editor. In my case, it happen to be gedit. Hence we use

gksudo gedit /etc/squid/squid.conf

Now, append the following line to the the file

cache_peer [current proxy server] parent [current proxy port] 0 no-query default proxy-only login=[user]:[pass]
acl all src 0.0.0.0/0.0.0.0
never_direct allow all

Now save the file and exit. Then isuue the command

sudo /etc/init.d/squid restart

Now, you have a proxy running at localhost on port 3128 which requires no authentication.
Enjoy.

No comments: