nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Squid Restriction

This is a discussion on Squid Restriction within the Proxy Servers forums, part of the Mastering Servers category; Hi All, I am using Squid Proxy in my lan it's working fine. Now i want to restrict some ip's ...


Go Back   nixCraft Linux Forum > Mastering Servers > Proxy Servers

Linux answers from nixCraft.


Proxy Servers Discussion about UNIX / Linux caching proxy servers, web proxy, reverse / content filtering proxy server.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 20-10-2008, 11:58 AM
Junior Member
User
 
Join Date: Sep 2008
OS: Debian
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
vlinux1 is on a distinguished road
Default Squid Restriction

Hi All,

I am using Squid Proxy in my lan it's working fine. Now i want to restrict some ip's for particular websites is there any way to do this.

I want to do following.......

I want to give access to www.yahoo.com,www.gmail.com,www.hotmail.com, etc. to this ips 192.168.1.5 (6,8,10,25,55) only mentioned must be able to access this sites. All other ip must be restrict.

Thanks In Advance

VJ
Reply With Quote
  #2 (permalink)  
Old 25-11-2008, 04:06 PM
Junior Member
User
 
Join Date: Oct 2008
OS: SUSE
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
st-evo is on a distinguished road
Default

acl yahoo dstdomain Yahoo!
acl allowip src 192.168.1.5 192.168.1.6 192.168.1.8 192.168.1.10 192.168.1.25 192.168.1.55

http_access allow allowip yahoo
http_access deny yahoo all

That should work, might not be lol. I found it easier in squidGuard to do it as it allows easier blocking for IP's
Reply With Quote
  #3 (permalink)  
Old 06-12-2008, 09:15 PM
giri's Avatar
Junior Member
User
 
Join Date: Nov 2008
OS: Red Hat
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
giri is on a distinguished road
Default restrictions

y dont u try this i may work


acl weballow 192.168.1.5 192.168.1.6 192.168.1.8 192.168.1.10 192.168.1.25 192
http_access allow weballow
acl myallow url_regex .google.com .yahoo.com .hotmail.com
http_access alllow myallow
Reply With Quote
  #4 (permalink)  
Old 03-01-2010, 03:43 PM
Junior Member
User
 
Join Date: Dec 2009
OS: Ubuntu 9.04
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
bandcoach is on a distinguished road
Default

Quote:
Originally Posted by vlinux1 View Post
Hi All,

I am using Squid Proxy in my lan it's working fine. Now i want to restrict some ip's for particular websites is there any way to do this.
I want to do following.......
I want to give access to www.yahoo.com,www.gmail.com,www.hotmail.com, etc. to this ips 192.168.1.5 (6,8,10,25,55) only mentioned must be able to access this sites. All other ip must be restrict.
Thanks In Advance
VJ
good answers so far. Something a little more robust and more easily editable (you won't need to keep editing squid.conf after this, just the files that it points to)

Using Giri's idea we go one step further:
Create a file in
Code:
/usr/local/squid/etc
call it
Code:
allowed-ips
do this using

Code:
bash# sudo touch allowed-ips # if you are in the directory or 
bash# sudo touch /usr/local/squid/etc/allowed-ips
add the ips you want to allow to this file one per line

Code:
192.168.1.5
192.168.1.6
192.168.1.8
192.168.1.10
192.168.1.25
192.168.1.55
this is no different to doing the following inside of squid.conf

Code:
acl allowed-ips src 192.168.1.5
acl allowed-ips src 192.168.1.6
acl allowed-ips src 192.168.1.8
acl allowed-ips src 192.168.1.10
acl allowed-ips src 192.168.1.25
acl allowed-ips src 192.168.1.55
and then using the acl name (allowed-ips) in http_access rule

make sure that squid can read this file. at the command line type
Code:
sudo chmod -R 644
now create a new file called
Code:
allowed-sites
also in
Code:
/usr/local/squid/etc
.

to this add each url one per line
Code:
.google.com
.yahoo.com
.hotmail.com
again, make sure that squid can read this file

Now change the acl lines in your squid .conf to read

Code:
acl weballow src "/usr/local/squid/etc/allowed-ips"
acl myallow url_regex "/usr/local/squid/etc/allowed-sites"
remembering that squid only parses the conf file until it finds a match, to achieve your aim you need to combine these rules into a single http_access rules

Code:
http_access allow weballow myallow
what happens here is squid looks to see if the ip is a permitted ip, if it is it then checks to see if the url is also permitted. Only if both are true will the site be allowed on the users machine.

Make sure that you put the above line above (before) any other http_access lines that may match one of the conditions and allow other users out to these sites. Also don't forget to have a http_access rule that allows these users to access other sites as well, if they are permitted, otherwise they will only ever be able to see these ones.

Using compounded acls you can create pretty complex access rules.

As you choose to add or remove permitted users and sites, you just edit the two files allowed-ips and allowed-sites to keep everything up-to-date.

Oh, yeah don't forget to restart or reload your squid

Code:
/etc/init.d/squid restart or /etc/init.d/squid reload
Shane

Last edited by bandcoach; 03-01-2010 at 03:46 PM. Reason: restart/reload squid added
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Postfix Users Send Mail Restriction caron_k2000 Mail Servers 2 25-08-2008 01:39 AM
vsftpd need restriction kasimani Networking, Firewalls and Security 1 12-03-2007 03:35 AM


All times are GMT +5.5. The time now is 12:46 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38