1、配置IP地址
过程略.....
2、编译安装Squid软件
[root@localhost ~]# tar -zxvf squid-3.4.6.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/squid-3.4.6/
[root@localhost squid-3.4.6]# ./configure
--prefix=/usr/local/squid
--sysconfdir=/etc
--enable-arp-acl
--enable-linux-netfilter
--enable-linux-tproxy
--enable-sasync-io=100
--enable-err-language="Simplify_Chinese"
--enable-underscore
--enable-poll
--enable-gnuregex
[root@localhost squid-3.4.6]# make
[root@localhost squid-3.4.6]# make install
3、创建用户并优化路径
[root@localhost ~]# useradd -M -s /sbin/nologin squid
[root@localhost ~]# ln -s /usr/local/squid/sbin/* /usr/local/sbin/
[root@localhost ~]# chown -R squid:squid /usr/local/squid/var/
[root@localhost ~]# chmod -R 757 /usr/local/squid/var/
4、检查语法并启动
[root@localhost ~]# squid -k parse
[root@localhost ~]# squid -z //清楚缓存
[root@localhost ~]# squid
[root@localhost ~]# netstat -anpt | grep squid
[root@localhost ~]# echo "/usr/local/squid/sbin/squid" > /etc/rc.local
[root@localhost ~]# killall -9 squid //停止squid服务
+++++++++++配置传统代理+++++++++++
-----WEB服务器------------Squid代理----------------Clinet--------
192.168.1.1 192.168.1.10 192.168.1.100
1、修改squid.conf配置文件
[root@localhost ~]# vim /etc/squid.conf
添加:
http_port 3128
reply_body_max_size 10 MB
http_access allow all
2、重启Squid服务
[root@localhost ~]# killall -9 squid
[root@localhost ~]# squid
3、客户端设置代理
打开IE浏览器:打开“工具”---“Internet选项”。“连接”---“局域网设置”中进行设置:
IP地址:192.168.1.10 端口:3128
4、验证:
客户端client访问WEB服务器http://192.168.1.1/
1)Squid代理服务器:
[root@localhost ~]# tail -f /usr/local/squid/var/logs/access.log //客户端访问了WEB服务器
2)WEB服务器:
[root@localhost ~]# tail -f /etc/httpd/logs/access_log //Squid服务器访问了WEB服务器
+++++++++++配置透明代理+++++++++++
-----WEB服务器------------Squid代理----------------Clinet--------
9.9.9.9 eth1:9.9.9.1
eth0:192.168.1.1 192.168.1.100
1、配置IP地址
注意:指定网关
(略)
2、开启路由转发功能
[root@localhost ~]# vim /etc/sysctl.conf
修改:
net.ipv4.ip_forward = 1
[root@localhost ~]#sysctl -p
3、修改squid.conf配置文件
[root@localhost ~]# vim /etc/squid.conf
添加:
http_port 192.168.1.1:3128 transparent
4、重启Squid服务
[root@localhost ~]# killall -9 squid
[root@localhost ~]# squid
5、设置防火墙规则
[root@localhost ~]#iptables -t nat -I PREROUTING -i eth0 -s 192.168.1.0/24 -p tcp --dport 80 -j REDIRECT --to-ports 3128
[root@localhost ~]#iptables -t nat -I PREROUTING -i eth0 -s 192.168.1.0/24 -p tcp --dport 443 -j REDIRECT --to-ports 3128
6、验证:
客户端client访问WEB服务器http://9.9.9.9/
1)Squid代理服务器:
[root@localhost ~]# tail -f /usr/local/squid/var/logs/access.log //客户端访问了WEB服务器
2)WEB服务器:
[root@localhost ~]# tail -f /etc/httpd/logs/access_log //Squid服务器访问了WEB服务器
+++++++++++配置ACL+++++++++++
拒绝访问
[root@localhost ~]# vim /etc/squid.conf
添加:
acl hee src all
http_access deny hee