Sunday, March 6, 2011

Single Interface Squid Proxy Server

This is a brief introduction to Squid proxy that covers Setting up Squid on Ubuntu/Debian with a single network card, and routing traffic through it. I use this for testing websites remotely before putting them live, but it would also be possible to setup a similar box to monitor network traffic.
Before you begin you should have a computer setup with Ubuntu/Debian. I am using Ubuntu 10.04 LTS for my proxy. The rest of these instructions will assume that this is installed and configured on your network as you want it. Also note that Debian users should su to root instead of typing sudo.
1. Get squid
First thing’s first, we need to get squid. This can be achieved by typing the following into  the terminal:
sudo apt-get install squid
This will download squid from the repositories and set it up on your machine.
2. Setup Squid
This is easy if you know what you’re doing. The squid config file is in the /etc/squid/ directory, so open it up in a text editor:
sudo nano /etc/squid/squid.conf
Now we need to add the lines to allow access to your network. If you’re in nano you can use
Ctrl+w and type acl all src all
Since I’m setting this up as a remote server I have to allow my IP address for work to be able to access the proxy. Here’s the lines I added:
acl remotenet src 123.123.123.123 #Work’s external IP address
further down the script there’s a line that reads http_access allow localnet, under this line add:
http_access allow remotenet #allow connections to this proxy server from “remotenet”
Understanding this process
ACL is an access control list, which you’re assigning IP addresses to. in the above two lines you’ve allowed the IP address 123.123.123.123 access to the proxy server. You can continue adding IP addresses to the remotenet group my copying and pasting the first line you entered but with different IP addresses.
At the end to the file you’ll also need to add the following line of code:
visible_hostname someProxyServerName
Exit and save the squid.conf file by pressing Ctrl+x and pressing Y when asked if you want to save changes, followed by enter to overwrite the file.
restart squid: sudo service squid restart
3. Setting  Up Your Web Browser
You should now be able to access your server by setting the proxy details up in your browser as the following:
Proxy: your squid IP address/DNS name
Port: 3128

courtesy of SIRNET

Squid Analysis Report Generator (SARG) and Webmin

The Squid Analysis Report Generator (SARG) enables you to see your Squid users internet usage. SARG provides many informations about Squid users activities like times, bytes, sites, etc. This article will show you how to use SARG through Webmin, a web-based interface for administering Linux.


Installing Webmin and SARG

RPM Forge 
1. Add the RPMforge repository into Yum. We will be getting the SARG RPM package for Red Hat/CentOS from RPMforge.
Yum install SARG 
2. From a terminal window, type in the command below to install SARG.
yum install sarg
Webmin 
3. Install Webmin. After installing, login to Webmin. Webmin will enable us to control who gets access to the Squid reports. We will also have an easy to use web-based interface for configuring the report format.
SARG configure 
4. Click Un-used modules in the side bar. Next click Squid Report Generator. We need to configure SARG so click module configuration.
SARG configure 
5. Change the value of Full path to SARG configuration file to /etc/sarg/sarg.conf then click the Save.
NoteNext time you need to use the Squid Report Generator, look for it under Servers instead of Un-used modules.

Generating a report

SARG 
1. To generate a report, click the Generate Report Now button.
SARG 
2. Next, click View completed report.
SARG 
3. Click the latest generated report.
SARG 
4. Review the generated report.