11 dạng cơ bản về ACL Squid

Ngày 25/11/2014 đăng bởi seo3.VS [email protected]

Sau đây tôi sẽ chia sẻ với các bạn 11 dạng cơ bản về  ACL Squid , hy vọng có thể giúp ích đựoc cho quý vị.

Cho phép truy cập web nhưng cấm vào các trang được chỉ định trước
acl allowip src “/etc/squid/allowip.txt”
acl denywebsite dstdom_regex “/etc/squid/denywebsite.txt”
http_access deny denywebsite
http_access allow allowip
# vi /etc/squid/allowip.txt >> địa chỉ lớp mạng vd: 192.168.1.0/24
# vi /etc/squid/denywebsite.txt >> dantri.com.vn
yahoo.com
# /etc/init.d/squid restart
Hạn chế truy cập web theo thời gian
acl home_network src 192.168.1.0/24
acl allow_hours time M T W H F 9:00-17:00
http_access allow home_network allow_hours
Hạn chế truy cập web theo thời gian và cấm các IP chỉ định đi web
acl home_network src 192.168.1.0/24
acl allow_hours time M T W H F 9:00-17:00
acl RestrictedHost src 192.168.1.200
http_access deny RestrictedHost
http_access allow home_network allow_hours
Hạn chế truy cập web theo thời gian và loại trừ IP của các sếp
acl home_network src 192.168.1.0/24
acl allow_hours time M T W H F 9:00-17:00
acl AllowHost src “/etc/squid/AllowHost.txt”
http_access allow AllowHost
http_access allow home_network allow_hours
# vi /etc/squid/AllowHost.txt
192.168.1.100
192.168.1.200
Hạn chế truy cập các website được ấn định trước
acl home_network src 192.168.1.0/24
acl allow_hours time M T W H F 9:00-17:00
acl Go***ites dstdomain “/etc/squid/Go***ites”
acl BadSites dstdomain “/etc/squid/BadSites”
http_access deny BadSites
http_access allow home_network allow_hours Go***ites
# vi /etc/squid/Go***ites
.vnlamp.com
.vnexpress.net
.dantri.com.vn
# vi /etc/squid/BadSites
.lauxanh.us
.dambut.com

>>> Xem thêm :  Huớng dẫn cài đặt và cấu hình Linux SQUID Proxy Server

Tự động redirect sang website ấn định trước khi truy cập những website ko được phép
acl home_network src 192.168.1.0/24
acl denywebsite dstdom_regex “/etc/squid/denywebsite.txt”
http_access deny denywebsite
deny_info http://vnlamp-test.vn/deny.html denywebsite >> tất nhiên đã cấu hình dns & httpd
#deny_info http://www.google.com.vn denywebsite >> redirect tới google
# deny_info TCP_RESET denywebsite >> reset the TCP connection (blank page)
http_access allow home_network
# vi /var/www/html/deny.html
“This site has restricted by administrator”
Hạn chế tên tập tin download
acl home_network src 192.168.1.0/24
acl blockfiles urlpath_regex “/etc/squid/block.files.acl”
http_access deny blockfiles
http_access allow home_network
hoặc
acl home_network src 192.168.1.0/24
acl denyfiletypes url_regex -i .mp3$ .mpg$ .mpeg$ .mp2$ .avi$ .wmv$ .wma$ .exe$
http_access deny denyfiletypes
http_access allow home_network
Dùng NCSA kiểm định password
Đầu tiên tạo một file password
# touch /etc/squid/squid_passwd
# chmod o+r /etc/squid/squid_passwd
Dùng htpasswd để add user và pass vào file squid_passwd mới tạo
# htpasswd /etc/squid/squid_passwd u1
New password:
Re-type new password:
Adding password for user u1
# Edit file squid.conf
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users
Cho phép một range IP chỉ truy cập vào những trang web cố định
acl allow_domains dstdomain url_regex “/etc/squid/local/access-local.txt”
acl ip-local src “/etc/squid/ip-local.txt”
http_access deny ip-local !allow_domains
http_access allow ip-local
# vi /etc/squid/local/access-local.txt
.vnexpress.net
.tuoitre.com.vn
# vi /etc/squid/local/ip-local.txt
192.168.1.0/24
Cấm truy cập vào yahoo
acl aclyahoo dstdomain pager.yahoo.com
acl aclyahoo dstdomain shttp.msg.yahoo.com
acl aclyahoo dstdomain update.pager.yahoo.com
acl aclyahoo dstdomain scsa.yahoo.com
acl aclyahoo dstdomain msg.yahoo.com
http_access deny aclyahoo
Cấm download file có dung lượng >=10MB
acl home_network src 192.168.2.0/24
acl denywebsite dstdom_regex “/etc/squid/denywebsite.txt”
http_access deny denywebsite
deny_info http://www.google.com.vn denywebsite
reply_body_max_size 10000000 allow home_network
http_access allow home_network
http_access deny all
icp_access allow all
Cấu hình Squid Proxy Server để điều khiển băng thông
Bước 1: Thêm vào trong file cấu hình squid một số phần như sau:
# vi /etc/squid/squid.conf
# Add Control Bandwith
acl ip src “/etc/squid/ip.txt” # ip trong file ip.txt bị giới hạn
acl all src 0.0.0.0/0.0.0.0
# Add Control Bandwith
delay_pools 1
delay_class 1 2
delay_access 1 allow ip
delay_access 1 deny all
delay_parameters 1 -1/-1 15000/15000
Với delay_parameters 1 -1/-1 15000/15000 ta sẽ giới hạn băng thông cho các client không thể vượt quá 15000 tương đương 15Kbps
Bước 2: Tạo file ip.txt như sau:
# vi /etc/squid/ip.txt
192.168.1.33
192.168.1.34
Vậy các IP trong file ip.txt sẽ có băng thông tối đa là 15Kbps

Block online streaming of Audio/Video
acl BlockExt url_regex -i .mp3$ .asx$ .wma$ .wmv$ .avi$ .mpeg$ .mpg$ .qt$ .ram$ .rm$ .iso$ .wav$ .exe$

acl webRadioReq1 req_mime_type -i ^video/x-ms-asf$
acl webRadioReq2 req_mime_type -i ^application/vnd.ms.wms-hdr.asfv1$
acl webRadioReq3 req_mime_type -i ^application/x-mms-framed$
acl webRadioRep1 rep_mime_type -i ^video/x-ms-asf$
acl webRadioRep2 rep_mime_type -i ^application/vnd.ms.wms-hdr.asfv1$
acl webRadioRep3 rep_mime_type -i ^application/x-mms-framed$

acl WMP browser Windows-Media-Player/*

http_access deny BlockExt !UtentiGold
http_access deny WMP all
http_access deny webRadioReq1 all
http_access deny webRadioReq2 all
http_access deny webRadioReq3 all

http_reply_access deny webRadioRep1 all
http_reply_access deny webRadioRep2 all
http_reply_access deny webRadioRep3 all

( 1. Added the extensions .wma and .wmv at the following line, so it’s impossible to dowlonload these file types acl BloccoExt url_regex -i .mp3$ .asx$ .wma$ .wmv$ .avi$ .mpeg$ .mpg$ .qt$ .ram$ .rm$ .iso$ .wav$ .exe$

2. Created acl for the other two 2 mime types (maybe not necessary) acl webRadioReq1 req_mime_type -i ^video/x-ms-asf$ acl webRadioReq2 req_mime_type -i ^application/vnd.ms.wms-hdr.asfv1$ acl webRadioReq3 req_mime_type -i ^application/x-mms-framed$ acl webRadioRep1 rep_mime_type -i ^video/x-ms-asf$ acl webRadioRep2 rep_mime_type -i ^application/vnd.ms.wms-hdr.asfv1$ acl webRadioRep3 rep_mime_type -i ^application/x-mms-framed$

3. Added this too… acl WMP browser Windows-Media-Player/*

4. Created following rules http_access deny BloccoExt !UtentiGold http_access deny WMP !UtentiGold http_access deny webRadioReq1 !UtentiGold http_access deny webRadioReq2 !UtentiGold http_access deny webRadioReq3 !UtentiGold

http_reply_access deny webRadioRep1 !UtentiGold http_reply_access deny webRadioRep2 !UtentiGold http_reply_access deny webRadioRep3 !UtentiGold

Notes:UtentiGold is an ip list of privileged users (CEO, ecc.)

In this mode, if I’m not a privileged user, I’m not able to open web radio (example http://bbwms.libero.it/lifegate) with IE6 and WMP9, clicking on a link or typing the url )

Chúc các bạn thành công!

.
.
.
.
Danh mục sản phẩm
024 7303 4068