NEWS CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
Home / News / Linux / Other Tips, Tricks and Tutorials

Other Tips, Tricks and Tutorials


Seting-Up a HTTP Proxy Server with Authentication and Filtering

Setting Squid to filter web content based on authentication credentials on Ubuntu and Fedora.

By Mihai Marinof, Linux Editor

19th of April 2007, 10:23 GMT

Adjust text size:


Squid Proxy Logo
Enlarge picture
A proxy server can allow computers to make indirect connections to other network services through the machine running the proxy. The most stable and commonly available proxy server for Linux is Squid: a proxy caching server for HTTP/FTP requests. Squid caches data from the Internet on your local network so the next time the same data is being accessed, whether it’s a web page or image file, it gets served-up from the local server rather than over the Internet. This will save you significant bandwidth but can also provide a few other advantages. For example, if you're at school and certain websites you'd like to visit are blocked, you can use your proxy server to access them. Also, another common use of Squid is for setting-up web filtering for kids. Whenever the browser is used, you will be prompted to enter a username and password, based on which the proxy will determine whether to filter the request or not.

Let's start by installing Squid. On Debian-based systems (Ubuntu), type the following command in a terminal (press Alt+F2, type gnome-terminal and press enter):
CODE
$ sudo apt-get install squid

On
systems running Fedora, type:
CODE
$ sudo yum install squid

Configure Squid by opening /etc/squid/squid.conf using your favorite text editor. In the configuration file, search for the following directives and modify (or add, if they don't exist) as it follows:

http_port 3128 - The port Squid will listen for connections. If your system has two or more interfaces, you can specify which IP address to use. Eg: http_port 192.168.0.1:3128

http_access deny all - Search for it in the config file, uncomment it (remove the # in front), and replace deny with allow so it becomes http_access allow all.

Restart the Squid proxy with:
CODE
$ sudo /etc/init.d/squid restart

Now you should have a fully functional HTTP proxy. To try it out, open a browser, open its preferences dialog and go to proxy settings. Here, enter the IP address of the machine running Squid and the port set in squid.conf. Now load a webpage.

SETTING UP SQUID AUTHENTICATION AND WEB FILTERING

This section will allow you to set up a web site filter for kids. The first time an address is entered in the browser's address bar, an authentication dialog will pop-up, prompting for a username and password. We will set-up two usernames, one with full and another with restricted access.

First, open the /etc/squid/squid.conf and add the following line in the auth_param section:

auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd

Now create the user accounts using htpasswd (use -c only for the first user):
CODE
$ sudo htpasswd -c /etc/squid/passwd dad
Enter a password for user 'dad':
Again:

$ sudo htpasswd /etc/squid/passwd kid
Another password:
Again:

Create the ACLs by adding the following lines in the ACCESS CONTROLS (acl) sections in Squid.conf:
CODE
acl dadUser proxy_auth dad
acl kidUser proxy_auth kid
acl whitelist dstdomain "/etc/squid/whitelist"
http_access allow dadUser
http_access allow kidUser whitelist

Create the whitelist by opening a text editor, adding allowed domains like this:
.google.com
.kids-play.com
.yahoo.com
.msn.com


and save it as /etc/squid/whitelist.

Finally, search for http_access allow all in the Squid config file and modify it so it looks like this:
http_access deny all

This is how my Squid config sections look like:
CODE
# NETWORK OPTIONS
# Squid normally listens to port 3128
http_port 192.168.0.1:3128

# TAG: auth_param
#Recommended minimum configuration per scheme:
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd

# ACCESS CONTROLS
# TAG: acl
acl dadUser proxy_auth dad
acl kidUser proxy_auth kid
acl whitelist dstdomain "/etc/squid/whitelist"
http_access allow dadUser
http_access allow kidUser whitelist

# TAG: http_access
# And finally deny all other access to this proxy
http_access deny all

Use deny all for squid with authentication and allow all for basic squid configuration.

TAGS:

squid | proxy | http proxy | web filter | filtering
Read by 50,734 user(s) | Add comment | Link to this article TWEET THIS


Article rating:
Good (3.3/5) 16 vote(s)    

Subscribe to news | Print article | Send to friend

© Copyright 2001-2009 Softpedia
Contact:

 

 

SEARCH THE NEWS ARCHIVE :




Today's News
| Yesterday's News | News Archive


MORE RELATED ARTICLES:


Install OpenOffice.org 2.1 in Ubuntu/Kubuntu

Fedora Core 6 Post-Install Guide

Install Kickoff KDE Menu in Kubuntu/Ubuntu

Monitoring a Linux System with X11/Console/Web-Based Tools

Create a LAN Repository with Apt-Cacher

Plone Installation Guide for Fedora Core 6

User opinions:


Comment #1 by: senthilkumar. K on 17 Jul 2008, 08:10 GMT reply to this comment

Hi,

I am used the above setup. It's working perfectly, If the user are open the internet will ask the username password.
Thank you very much.

With Regards
Senthilkumar. K
System Admin


Comment #2 by: junise safvan on 02 Jul 2009, 06:08 GMT reply to this comment

how can i add other computers to this proxy server.
i mean the other computers should browse through this proxy server.....


Comment #3 by: Kelvin Phan on 27 Sep 2009, 16:30 GMT reply to this comment

You need to use squid as a transparent proxy... meaning redirect port 80 to squid proxy port (3128) with iptables.

Run below cmd on command line.

iptables --table nat --append PREROUTING -p tcp -m tcp -i eth1 --dport 80 -j REDIRECT --to-ports 3128

where eth1 is your LAN.

Share your opinion:

Your Name:
Your Email Address:
(will not be used for commercial purposes)
Solve this to prove you're not a bot: =
Your review/opinion:

 




Windows tabGames tabDrivers tabMac tabLinux tabScripts tabMobile tabHandheld tabGadgets tabNews tab

SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   ENTER NEWS SITE   |   ENGLISH BOARD   |   ROMANIAN FORUM