02 squid proxy

22
Cài đặt, cấu hình Linux SQUID Proxy Server download tại đây: squid : Optimising Web Delivery có bản SQUID 3.0.RC1 Squid 3.0.STABLE7 configuration file ftp://mirror.aarnet.edu.au/pub/squid...TABLE16.tar.gz Squid là một proxy server, khả năng của squid là tiết kiệm băng thông(bandwidth), cải tiến việc bảo mật, tăng tốc độ truy cập web cho người sử dụng và trở thành một trong những proxy phổ biến được nhiều người biết đến. Hiện nay, trên thị trường có rất nhiều chương trình proxy-server nhưng chúng lại có hai nhược điểm, thứ nhất là phải trả tiền để sử dụng, thứ hai là hầu hết không hỗ trợ ICP ( ICP được sử dụng để cập nhật những thay đổi về nội dung của những URL sẵn có trong cache – là nơi lưu trữ những trang web mà bạn đã từng đi qua ). Squid là sự lựa chọn tốt nhất cho một proxy-cache server, squid đáp ứng hai yêu cầu của chúng ta là sử dụng miễn phí và có thể sử dụng đặc trưng ICP. - Squid đưa ra kỹ thuật lưu trữ ở cấp độ cao của các web client, đồng thời hỗ trợ các dịch vụ thông thường như FTP, Gopher và HTTP. Squid lưu trữ thông tin mới nhất của các dịch vụ trên trong RAM, quản lý một cơ sở dữ liệu lớn của các thông tin trên đĩa, có một kỹ thuật điều khiển truy cập phức tạp, hỗ trợ giao thức SSL cho các kết nối bảo mật thông qua proxy. Hơn nữa, squid có thể liên kết với các cache của các proxy server khác trong việc sắp xếp lưu trữ các trang web một cách hợp lý. - Sau đây chúng ta sẽ thực hiện cách thức cài đặt một Proxy server như thế nào.

Upload: le-duy-dong

Post on 31-Dec-2015

93 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 02 Squid Proxy

Cài đặt, cấu hình Linux SQUID Proxy Serverdownload tại đây:

squid : Optimising Web Delivery

có bản SQUID 3.0.RC1

Squid 3.0.STABLE7 configuration file

ftp://mirror.aarnet.edu.au/pub/squid...TABLE16.tar.gz

Squid là một proxy server, khả năng của squid là tiết kiệm băng thông(bandwidth), cải tiến việc bảo mật, tăng tốc độ truy cập web cho người sử dụng và trở thành một trong những proxy phổ biến được nhiều người biết đến. Hiện nay, trên thị trường có rất nhiều chương trình proxy­server nhưng chúng lại có hai nhược điểm, thứ nhất là phải trả tiền để sử dụng, thứ hai là hầu hết không hỗ trợ ICP ( ICP được sử dụng để cập nhật những thay đổi về nội dung của những URL sẵn có trong cache – là nơi lưu trữ những trang web mà bạn đã từng đi qua ). Squid là sự lựa chọn tốt nhất cho một proxy­cache server, squid đáp ứng hai yêu cầu của chúng ta là sử dụng miễn phí và có thể sử dụng đặc trưng ICP.

­ Squid đưa ra kỹ thuật lưu trữ ở cấp độ cao của các web client, đồng thời hỗ trợ các dịch vụ thông thường như FTP, Gopher và HTTP. Squid lưu trữ thông tin mới nhất của các dịch vụ trên trong RAM, quản lý một cơ sở dữ liệu lớn của các thông tin trên đĩa, có một kỹ thuật điều khiển truy cập phức tạp, hỗ trợ giao thức SSL cho các kết nối bảo mật thông qua proxy. Hơn nữa, squid có thể liên kết với các cache của các proxy server khác trong việc sắp xếp lưu trữ các trang web một cách hợp lý.

­ Sau đây chúng ta sẽ thực hiện cách thức cài đặt một Proxy server như thế nào.

Page 2: 02 Squid Proxy

2/ Cài đặt:

­ Đầu tiên chúng ta nên có một số khái niệm về đòi hỏi phần cứng của một proxy server:

****** Tốc độ truy cập đĩa cứng : rất quan trọng vì squid thường xuyên phải đọc và ghi dữ liệu trên ổ cứng. Một ổ đĩa SCSI với tốc độ truyền dữ liệu lớn là một ứng cử viên tốt cho nhiệm vụ này.

****** Dung lượng đĩa dành cho cache phụ thuộc vào kích cỡ của mạng mà Squid phục vụ. Từ 1 đến 2 Gb cho một mạng trung bình khoảng 100 máy. Tuy nhiên đây chỉ là một con số có tính chất ví dụ vì nhu cầu truy cập Internet mới là yếu tố quyết định sự cần thiết độ lớn của đĩa cứng.

****** RAM : rất quan trọng, ít RAM thì Squid sẽ chậm hơn một cách rõ ràng.

****** CPU : không cần mạnh lắm, khoảng 133 MHz là cũng có thể chạy tốt với tải là 7 requests/second.

­ Cài đặt Squid với RedHat Linux rất đơn giản. Squid sẽ được cài nếu bạn chọn nó trong quá trình cài đặt ngay từ đầu. Hoặc nếu bạn đã cài Linux không Squid, bạn có thể cài sau qua tiện ích rpm với lệnh :

rpm –i tên_gói_Squid

­ Khi đó squid sẽ được cài và bạn có thể bước qua phần cấu hình squid.

­ Các thư mục mặc định của squid:

/usr/sbin

/etc/squid

Page 3: 02 Squid Proxy

/var/log/squid

­ Cài đặt từ source :

+ Ta có file source của squid là squid­version.tar.gz, ta thực hiện các bước lệnh sau:

tar –xzvf squid­version.tar.gz

cd squid­version

./configure

make

make install

­ Sau khi ta thực hiện các lệnh trên, coi như ta đã cài đặt xong squid.

3/ Cấu hình Squid:

­ Sau khi cài đặt xong squid, ta phải cấu hình squid để phù hợp với từng yêu cầu riêng. Ta cấu hình một số tham số trong file /etc/squid/squid.conf như sau:

** http_port: mặc định là 3128.

** icp_port: mặc định là 3130.

** cache_dir: khai báo kích thước thư mục cache cho squid, mặc định là: cache_dir /var/spool/squid/cache 100 16 256

Page 4: 02 Squid Proxy

Giá trị 100 tức là dùng 100MB để làm cache, nếu dung lượng đĩa cứng lớn, ta có thể tăng thêm tuỳ thuộc vào kích thước đĩa. Như vậy squid sẽ lưu cache trong thư mục /var/spool/squid/cache với kích thước cache là 100MB.

** Access Control List và Access Control Operators: ta có thể dùng hai chức năng trên để ngăn chặn và giới hạn việc truy xuất dựa vào destination domain, IP address của máy hoặc mạng. Mặc định squid sẽ từ chối phục vụ tất cả, vì vậy ta phải cấu hình lại tham số này. Để được vậy, ta cấu hình thêm cho thích hợp với yêu cầu bằng hai tham số là : acl và http_access.

Ví dụ: Ta chỉ cho phép mạng 172.16.1.0/24 được dùng proxy server bằng từ khoá src trong acl.

acl MyNetwork src 172.16.1.0/255.255.255.0

http_access allow MyNetwork

http_access deny all

+ Ta cũng có thể cấm các máy truy xuất đến những site không được phép bằng từ khoá dstdomain trong acl, ví dụ:

acl BadDomain dstdomain yahoo.com

http_access deny BadDomain

http_access deny all

+ Nếu danh sách cấm truy xuất đến các site dài quá, ta có thể lưu vào 1 file text, trong file đó là danh sách các địa chủ như sau:

acl BadDomain dstdomain “/etc/squid/danhsachcam”

Page 5: 02 Squid Proxy

http_access deny BadDomain

+ Theo cấu hình trên thì file /etc/squid/danhsachcam là file văn bản lưu các địa chỉ không được phép truy xuất được ghi lần lượt theo từng dòng.

+ Ta có thể có nhiều acl, ứng với mỗi acl phải có một http_access như sau:

acl MyNetwork src 172.16.1.0/255.255.255.0

acl BadDomain dstdomain yahoo.com

http_access deny BadDomain

http_access allow MyNetwork

http_access deny all

+ Như vậy cấu hình trên cho ta thấy proxy cấm các máy truy xuất đến site Yahoo! và chỉ có mạng 172.16.1.0/24 là được phép dùng proxy. “http_access deny all”: cấm tất cả ngoại trừ những acl đã được khai báo.

­ Nếu proxy không thể kết nối trực tiếp với Internet vì không có địa chỉ IP thực hoặc proxy nằm sau một Firewall thì ta phải cho proxy query đến một proxy khác có thể dùng Internet bằng tham số sau :

cache_peer linuxsrv.mcsevn.com parent 8080 8082

+ Cấu hình trên cho chúng ta thấy proxy sẽ query lên proxy “cha” là linuxsrv.mcsevn.com với tham số parent thông qua http_port là 8080 và icp_port là 8082.

­ Ngoài ra trong cùng một mạng nếu có nhiều proxy server thì ta có thể cho các proxy server này query lẫn nhau như sau:

Page 6: 02 Squid Proxy

cache_peer proxy2.mcsevn.com sibling 8080 8082

cache_peer proxy3.mcsevn.com sibling 8080 8082

sibling dùng cho các proxy ngang hàng với nhau.

4/ Khởi động Squid:

­ Sau khi đã cài đặt và cấu hình lại squid, ta phải tạo cache trước khi chạy squid bằng lệnh:

squid –z

­ Nếu trong quá trình tạo cache bị lỗi, ta chú ý đến các quyền trong thư mục cache được khai báo trong tham số cache_dir. Có thể thư mục đó không được phép ghi. Nếu có ta phải thay đổi bằng:

chown squid:squid /var/spool/squid

chmod 770 /var/spool/squid

­ Sau khi tạo xong thư mục cache, ta khởi động và dừng squid bằng script như sau:

/etc/init.d/squid star

/etc/init.d/squid stop

­ Sau khi squid đã khởi động, muốn theo dõi và quản lý việc truy cập của các client hay những gì squid đang hoạt động cache như thế nào, ta thường xuyên 

Page 7: 02 Squid Proxy

xem xét những file sau đây:

****** cache_log: bao gồm những cảnh báo và thông tin trạng thái của cache

****** store_log: bao gồm những cơ sở dữ liệu về những thông tin gì mới được cập nhật trong cache và những gì đã hết hạn

****** access_log: chứa tất cả những thông tin về việc truy cập của client, bao gồm địa chỉ nguồn, đích đến, thời gian……

Một số ví dụ về ACL SquidCho phép truy cập web nhưng cấm vào các trang được chỉ định trướcacl allowip src "/etc/squid/allowip.txt"acl denywebsite dstdom_regex "/etc/squid/denywebsite.txt"http_access deny denywebsitehttp_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.vnyahoo.com# /etc/init.d/squid restartHạn chế truy cập web theo thời gianacl home_network src 192.168.1.0/24acl allow_hours time M T W H F 9:00­17:00http_access allow home_network allow_hoursHạn chế truy cập web theo thời gian và cấm các IP chỉ định đi webacl home_network src 192.168.1.0/24acl allow_hours time M T W H F 9:00­17:00acl RestrictedHost src 192.168.1.200http_access deny RestrictedHosthttp_access allow home_network allow_hoursHạn chế truy cập web theo thời gian và loại trừ IP của các sếpacl home_network src 192.168.1.0/24

Page 8: 02 Squid Proxy

acl allow_hours time M T W H F 9:00­17:00acl AllowHost src "/etc/squid/AllowHost.txt"http_access allow AllowHosthttp_access allow home_network allow_hours# vi /etc/squid/AllowHost.txt192.168.1.100192.168.1.200Hạn chế truy cập các website được ấn định trướcacl home_network src 192.168.1.0/24acl allow_hours time M T W H F 9:00­17:00acl Go***ites dstdomain "/etc/squid/Go***ites"acl BadSites dstdomain "/etc/squid/BadSites"http_access deny BadSiteshttp_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.comTự động redirect sang website ấn định trước khi truy cập những website ko được phépacl home_network src 192.168.1.0/24acl denywebsite dstdom_regex "/etc/squid/denywebsite.txt"http_access deny denywebsitedeny_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

Page 9: 02 Squid Proxy

"This site has restricted by administrator"Hạn chế tên tập tin downloadacl home_network src 192.168.1.0/24acl blockfiles urlpath_regex "/etc/squid/block.files.acl"http_access deny blockfileshttp_access allow home_networkhoặcacl home_network src 192.168.1.0/24acl denyfiletypes url_regex ­i .mp3$ .mpg$ .mpeg$ .mp2$ .avi$ .wmv$ .wma$ .exe$http_access deny denyfiletypeshttp_access allow home_networkDù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_passwdDùng htpasswd để add user và pass vào file squid_passwd mới tạo# htpasswd /etc/squid/squid_passwd u1New password:Re­type new password:Adding password for user u1# Edit file squid.confauth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwdacl ncsa_users proxy_auth REQUIREDhttp_access allow ncsa_usersCho phép một range IP chỉ truy cập vào những trang web cố địnhacl 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_domainshttp_access allow ip­local# vi /etc/squid/local/access­local.txt.vnexpress.net.tuoitre.com.vn

Page 10: 02 Squid Proxy

# vi /etc/squid/local/ip­local.txt192.168.1.0/24Cấm truy cập vào yahooacl aclyahoo dstdomain pager.yahoo.comacl aclyahoo dstdomain shttp.msg.yahoo.comacl aclyahoo dstdomain update.pager.yahoo.comacl aclyahoo dstdomain scsa.yahoo.comacl aclyahoo dstdomain msg.yahoo.comhttp_access deny aclyahooCấm download file có dung lượng >=10MBacl home_network src 192.168.2.0/24acl denywebsite dstdom_regex "/etc/squid/denywebsite.txt"http_access deny denywebsitedeny_info http://www.google.com.vn denywebsitereply_body_max_size 10000000 allow home_networkhttp_access allow home_networkhttp_access deny allicp_access allow allCấu hình Squid Proxy Server để điều khiển băng thôngBướ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 Bandwithacl ip src "/etc/squid/ip.txt" # ip trong file ip.txt bị giới hạnacl all src 0.0.0.0/0.0.0.0# Add Control Bandwithdelay_pools 1delay_class 1 2delay_access 1 allow ipdelay_access 1 deny alldelay_parameters 1 ­1/­1 15000/15000Vớ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 15KbpsBước 2: Tạo file ip.txt như sau:

Page 11: 02 Squid Proxy

# vi /etc/squid/ip.txt192.168.1.33192.168.1.34Vậy các IP trong file ip.txt sẽ có băng thông tối đa là 15Kbps

# Block online streaming of Audio/Videoacl 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 !UtentiGoldhttp_access deny WMP allhttp_access deny webRadioReq1 allhttp_access deny webRadioReq2 allhttp_access deny webRadioReq3 all

http_reply_access deny webRadioRep1 allhttp_reply_access deny webRadioRep2 allhttp_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 

Page 12: 02 Squid Proxy

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 )Proxy toàn tập (Squid + SquidGuard + IPTables + Sarg + Webmin) ________________________________________Network Topology===========> Network Toplogy<====================Internet <==>Modem 192.168.1.1/24 <==192.168.1.2 Proxy/NAT192.168.0.1/24==>HUB LAN_ 192.168.0.0/24Thông cảm không up hình được============================================I. Install Squid:Code:

Page 13: 02 Squid Proxy

[root@ProxyServer ~]# yum ­y install squidComplete![root@ProxyServer ~]# vi /etc/squid/squid.conf http_port :3128 # line 73: changecache_mem 512 MB # RAM/3cache_dir ufs /hdd160G/squid/cache 10000 16 256access_log /hdd160G/squid/log/access.log squidcache_log /hdd160G/squid/log/cache.logcache_store_log /hdd160G/squid/log/store.logacl all src 0.0.0.0/0.0.0.0acl manager proto cache_objectacl localhost src 127.0.0.1/255.255.255.255acl to_localhost dst 127.0.0.0/8acl SSL_ports port 443acl Safe_ports port 80 # httpacl Safe_ports port 21 # ftpacl Safe_ports port 443 # httpsacl Safe_ports port 70 # gopheracl Safe_ports port 210 # waisacl Safe_ports port 1025­65535 # unregistered portsacl Safe_ports port 280 # http­mgmtacl Safe_ports port 488 # gss­httpacl Safe_ports port 591 # filemakeracl Safe_ports port 777 # multiling httpacl CONNECT method CONNECT

acl MyNetwork1 src 192.168.0.0/255.255.255.0acl MyNetwork2 src 192.168.1.0/255.255.255.0acl MyNetwork3 src 192.168.2.0/255.255.255.0

Page 14: 02 Squid Proxy

http_access allow manager MyNetwork1http_access allow manager MyNetwork2http_access allow manager MyNetwork3http_access allow MyNetwork1http_access allow MyNetwork2http_access allow MyNetwork3http_access deny all[root@ProxyServer ~]#service squid startinit_cache_dir /var/spool/squid... Starting squid: [ OK ][root@ProxyServer ~]# chkconfig squid on

II. Install SquidGuard Code:[root@ProxyServer ~]# yum ­y install squidguardComplete![root@ProxyServer ~]# vi /usr/local/squidGuard/squidGuard.conf dbhome /usr/local/squidGuard/dblogdir /usr/local/squidGuard/logtime workhours {weekly mtwhf 08:00 ­ 16:30date *­*­01 08:00 ­ 16:30}destination bl_hacking {domainlist blacklists/hacking/domainsurllist blacklists/hacking/urls}

rew dmz {s@://admin/@://admin.foo.bar.de/@i

Page 15: 02 Squid Proxy

s@://foo.bar.de/@://www.foo.bar.de/@i}src admin {ip 1.2.3.4 1.2.3.5user root foo barwithin workhours}

src foo­clients {ip 172.16.2.32­172.16.2.100 172.16.2.100 172.16.2.200}

src bar­clients {ip 192.168.2.0/26}dest good {}

dest local {}

acl {admin {pass any}

foo­clients within workhours {pass good !in­addr any} else {

Page 16: 02 Squid Proxy

pass all}

bar­clients {pass !bl_hacking all}

default {pass !bl_hacking allrewrite dmzredirect http://www.google.com}}III. Config IPTables bước này khá quan trọng trong thực tế. Thi linux LPI thì không cần hihiVì có nó thì mail outlook mới In out được nha. Tui đã từng chết chổ nàyhttp://nhatnghe.vn/forum/showthread.php?t=8977Code:[root@ProxyServer ~]# vi /etc/sysconfig/iptables# Generated by iptables­save v1.3.5 on Tue Feb 24 16:40:48 2009*filter:INPUT ACCEPT [11305:6933866]:FORWARD ACCEPT [463:57229]:OUTPUT ACCEPT [10851:7011776]­A FORWARD ­s 192.168.0.3 ­d 192.168.2.1 ­i eth1 ­o eth2 ­p tcp ­m state ­­state NEW ­j ACCEPT ­A FORWARD ­s 192.168.0.3 ­d 192.168.2.1 ­i eth1 ­o eth2 ­p udp ­m state ­­state NEW ­j ACCEPT COMMIT

Page 17: 02 Squid Proxy

# Completed on Tue Feb 24 16:40:48 2009# Generated by iptables­save v1.3.5 on Tue Feb 24 16:40:48 2009*mangle:PREROUTING ACCEPT [11768:6991095]:INPUT ACCEPT [11305:6933866]:FORWARD ACCEPT [463:57229]:OUTPUT ACCEPT [10851:7011776]:POSTROUTING ACCEPT [11324:7069325]COMMIT# Completed on Tue Feb 24 16:40:48 2009# Generated by iptables­save v1.3.5 on Tue Feb 24 16:40:48 2009*nat:PREROUTING ACCEPT [335:40971]:POSTROUTING ACCEPT [5:268]:OUTPUT ACCEPT [149:8897]­A PREROUTING ­i eth0 ­p tcp ­m tcp ­­dport 80 ­j REDIRECT ­­to­ports 3128 ­A PREROUTING ­i eth1 ­p tcp ­m tcp ­­dport 80 ­j REDIRECT ­­to­ports 3128 ­A PREROUTING ­i eth2 ­p tcp ­m tcp ­­dport 80 ­j REDIRECT ­­to­ports 3128 ­A PREROUTING ­i eth1 ­p tcp ­j DNAT ­­to­destination 192.168.2.1 ­A PREROUTING ­i eth1 ­p udp ­j DNAT ­­to­destination 192.168.2.1 ­A POSTROUTING ­o eth1 ­j MASQUERADE COMMIT# Completed on Tue Feb 24 16:40:48 2009# Generated by iptables­save v1.3.5 on Tue Feb 24 16:40:48 2009*raw:PREROUTING ACCEPT [11768:6991095]:OUTPUT ACCEPT [10851:7011776]COMMIT# Completed on Tue Feb 24 16:40:48 2009

Page 18: 02 Squid Proxy

IV. Install SargCode:[root@ProxyServer ~]# yum ­y install sargComplete![root@ProxyServer ~]# vi /etc/sarg/sarg.confaccess_log /hdd160G/squid/log/access.logSquid Analysis Report GeneratorSarg ­ Squid Analysis Report Generator is a tool that allow you to view "where" your users are going to on the Internet. Sarg provides many informations about Squid users activities: times, bytes, sites, etc..

V. Install WedminCode:[root@ProxyServer ~]# wget http://jaist.dl.sourceforge.net/sour...0­1.noarch.rpm[root@ProxyServer ~]# rpm ­Uvh webmin­1.360­1.noarch.rpmWebmin install complete. You can now login to https://ns.server­linux.info:10000/as root with your root password.[root@ProxyServer ~]# vi /etc/webmin/miniserv.confallow=127.0.0.1 192.168.0.0/24 #bottom: add IPs you permit to access[root@ProxyServer ~]# wget ttp://www.niemueller.de/webmin/modules/squidguard/squidguard­0.91.2.wbm.gzThe installation is quite simple: Login to your Webmin as admin (or whatever you called the adminstrative user) and go to the Webmin tab, then choose "Webmin Configuration". Now click on "Webmin Modules". Give the file in the first box (you can choose any installation method, all should work). Hit Install. Now the module is being installed.

Page 19: 02 Squid Proxy

VI. Other config

Log rotationBước này trong LAB không làm cũng không sao, trên thực tế không làm là Sever Die do quá tai nha. Linux quản lý file có dung lượng lớn không được tốt cho lám. Và trong bài này chúng ta chuyến cache đến HDD160G không phải Folder Default Code:[root@ProxyServer ~]# vi /etc/logrotate.conf# see "man logrotate" for details# rotate log files weeklyweekly# keep 4 weeks worth of backlogsrotate 4# create new (empty) log files after rotating old onescreate# use date as a suffix of the rotated filedateext# uncomment this if you want your log files compressed#compress# RPM packages drop log rotation information into this directoryinclude /etc/logrotate.d# no packages own wtmp and btmp ­­ we'll rotate them here/var/log/wtmp {monthlycreate 0664 root utmprotate 1

Page 20: 02 Squid Proxy

}/var/log/btmp {missingokmonthlycreate 0600 root utmprotate 1}# system­specific logs may be also be configured here.Code:[root@ProxyServer ~]# vi /etc/logrotate.d/squid/hdd160G/squid/log/access.log {weeklyrotate 5copytruncatecompressnotifemptymissingok}/hdd160G/squid/log/cache.log {weeklyrotate 5copytruncatecompressnotifemptymissingok}

/hdd160G/squid/log/store.log {weekly

Page 21: 02 Squid Proxy

rotate 5copytruncatecompressnotifemptymissingok# This script asks squid to rotate its logs on its own.# Restarting squid is a long process and it is not worth# doing it just to rotate logspostrotate/usr/sbin/squid ­k rotateendscript}

How to configure Internet Explorer to use a proxy serverIE > Tools>Internet options>Connections>LAN Settings>1. On the Tools menu in Internet Explorer, click Internet Options, click the Connections tab, and then click LAN Settings.2. Under Proxy server, click to select the Use a proxy server for your LAN check box.3. In the Address box, type the IP address of the proxy server: 192.168.0.1.4. In the Port box, type the port number 3128 that is used by the proxy server for client connections (by default, 8080).5. You can click to select the Bypass proxy server for local addresses check box if you do not want the proxy server computer to be used when you connect to a computer on the local network (this may speed up performance).6. Click OK to close the LAN Settings dialog box.7. Click OK again to close the Internet Options dialog box.Service squid restart

Page 22: 02 Squid Proxy

Service httpd restartService network restartService iptables restart