[root@localhost ~]# tail -f /var/log/squid/access.log //通过下面的日志可以看到访问百度是得到200,304这样的正常状态回复,而qq.com则是403错误
1270605192.840 308 192.168.122.50 TCP_MISS/200 2349 GET - DIRECT/121.14.88.76 text/html
1270605192.900 59 192.168.122.50 TCP_MISS/304 289 GET ? - DIRECT/121.14.89.10 -
1270605216.007 95 192.168.122.50 TCP_DENIED/403 1441 GET - NONE/- text/html
1270605216.095 1 192.168.122.50 TCP_DENIED/403 1463 GET - NONE/- text/html
1270605219.080 0 192.168.122.50 TCP_DENIED/403 1463 GET - NONE/- text/html
2:实现squid代理需要提供用户名和密码进行认证
[root@localhost ~]# grep 'ncsa' /etc/squid/squid.conf
auth_param basic program /usr/libexec/ncsa_auth /usr/etc/passwd
[root@localhost ~]# file /usr/libexec/ncsa_auth
/usr/libexec/ncsa_auth: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
//该二进制文件默认不存在,已上传至CSDN,下载地址:
[root@localhost ~]# htpasswd -cm /usr/etc/passwd zhangsan
New password:
Re-type new password:
Adding password for user zhangsan
[root@localhost ~]# grep 'auth_user' /etc/squid/squid.conf
acl auth_user proxy_auth REQUIRED
http_access allow auth_user
[root@localhost ~]# chmod 755 /usr/libexec/ncsa_auth
[root@localhost ~]# chmod 755 /usr/etc/passwd
[root@localhost ~]# service squid restart
[root@localhost ~]# tail /var/log/squid/access.log
1270610989.514 75 192.168.122.1 TCP_MISS/200 2146 GET
RedHat.com/g/home_promos/pause.png zhangsan DIRECT/58.63.242.112 image/png
1270610990.016 648 192.168.122.1 TCP_MISS/200 2195 CONNECT inquiries.redhat.com:443
zhangsan DIRECT/64.13.137.22 -1270610990.659 606 192.168.122.1 TCP_MISS/200 2585 CONNECT inquiries.redhat.com:443 zhangsan DIRECT/64.13.137.22 -1270611001.206 224 192.168.122.1 TCP_MISS/200 1406 POST ? zhangsan DIRECT/72.14.203.113 application/vnd.google.safebrowsing-update