Wednesday, January 5, 2011

How to setup squid proxy server in ubuntu (10.04 but may apply in other versions)



Installation

At a terminal prompt, enter the following command to install the Squid server:


sudo apt-get install squid squid-common

Configuration

Squid is configured by editing the directives contained within the /etc/squid/squid.conf configuration file. The following examples illustrate some of the directives which may be modified to affect the behavior of the Squid server. For more in-depth configuration of Squid, see the References section.

Prior to editing the configuration file, you should make a copy of the original file and protect it from writing so you will have the original settings as a reference, and to re-use as necessary.
Copy the /etc/squid/squid.conf file and protect it from writing with the following commands entered at a terminal prompt:


sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.original
sudo chmod a-w /etc/squid/squid.conf.original
  • Set the following in squid.conf:
    http_port 8080
    icp_port 0
    acl river_network src 112.198.99.00/32
    http_access allow river_network
    icp_access allow all
  • Be sure to set your port forwarding in router to:
    starting port: 8080
    ending port: 8080
    protocol: TCP
    ip: 192.168.0.4 (replace this with the local ip of your squid server)
  • Restart squid using:
    sudo /etc/init.d/squid restart
    or
    squid restart
  • Test Squid using Firefox brower
    Go to Edit -> Preferences -> Advanced -> Network -> Settings
    Select Manual proxy configuration
    Provide the squid server IP in the HTTP Proxy field
    Set the Port to 8080
    Check "Use this proxy for all protocols"
    Click Ok
    Click Close
  • Testing the configuration
    Open up a random website you know wouldn’t resolve e.g http://www.squid.rox/ to test the proxy is running. You should get an error like Generated Tue, 24 Aug 2010 16:55:49 GMT by squid (squid/2.7.STABLE7). Next open up a few valid websites to build up the squid cache.
  • Validating the caching is working
    Switch back to your Ubuntu Linux Squid (Squid-cache) box and open up a terminal. If you changed your cache_dir location like I did then do sudo ls -laFo /var/spool/squid/ else, substitute the path for yours.
  • Done!

No comments:

Post a Comment