教程集 www.jiaochengji.com
教程集 >  服务器技术  >  应用加速  >  正文 squid代理配置一例

squid代理配置一例

发布时间:2014-07-20   编辑:jiaochengji.com
squid代理配置一例,配置目标:客户端可以使用浏览器浏览网页,但不能上QQ,下载,FOXMAIL收发邮件等

配置目标:客户端可以使用浏览器浏览网页,但不能上QQ,下载,FOXMAIL收发邮件等

环境要求:
服务端两块网卡
外网网卡eth0,IP:121.15.134.2
内网网卡eth1,IP:192.168.20.2/24
squid版本: squid-2.6.STABLE6-5.el5_1.3

1.# rpm -qa|grep squid
squid-2.6.STABLE6-5.el5_1.3
如没有安装该插件yum安装

2.squid服务器的初始化
第一次使用squid,需先初始化

注意:如果初始化成功的话,会显示:2008/06/20 15:07:51| Creating Swap Directories
如果显示的是这样的信息的话:FATAL: Could not determine fully qualified hostname.Please set 'visible_hostname'
Squid Cache (Version 2.5.STABLE6): Terminated abnormally.
CPU Usage: 0.064 seconds = 0.008 user + 0.056 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0
Aborted
我们需要在主配置文件中添加一行:
# vi /etc/squid/squid.conf
visible_hostname squid //其中squid为你当前主机的名称
保存退出后,再次执行squid -z就可以了。

本试验直接初始化通过
# squid -z

3.# ls /var/spool/squid/
000102030405060708090A0B0C0D0E0Fswap.state

启动squid服务
# service squid start

4.修改squid服务器的配置文件
# vi /etc/squid/squid.conf

找到如下行:
http_port 3128
把它修改为
BPCS 里的数据字典文件如何-

http_port 3128 8080 或
http_port 8080
squid服务器的服务端口使用http_port配置项设置,默认值时3128,为了方便用户使用,可以更改为8080,或在多个端口提供服务。http_port配置项支持在多个端口提供代理服务
本例没做修改,使用默认的3128
找到如下行:
cache_mem 8 MB
把它修改为:
cache_mem 64 MB
这行是用来设置缓冲内存数量的,squid服务器的性能和squid服务器使用的缓冲内存数量有很大的关系,一般来讲,使用内存越多,squid服务器的性能会越好,可以根据需要配置

找到如下行:
cache_dir ufs /var/spool/squid 100 16 256
这行用来设置squid服务器的工作目录路径和属性,其中"100 16 256"分别表示目录中最大的容量时100MB,目录中的一级子目录的数量为16个,二级子目录为256个。在实际应用中

可根据实际情况适当调整

5.配置访问配置
squid服务器中提供了强大的访问控制功能,在squid.conf配置文件中,访问控制功能时由http_access和acl配置项共同实现的
# grep ^acl /etc/squid/squid.conf
acl QUERY urlpath_regex cgi-bin ?
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https,amp连接器 snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535# unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT

# grep ^http_access /etc/squid/squid.conf
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all

添加一项访问控制列表
# vi /etc/squid/squid.conf
acl mynetwork src 192.168.20.0/24 //此行需要添加到acl设置项中去
http_access allow mynetwork //此行要在squid.conf文件的http_access deny all设置行前添加

重新启动squid服务
# service squid restart

6.客户端验证
打开客户端浏览器
点击IE“工具”,在弹出的窗口中找到"连接"—"局域网设置",选择代理服务器,勾选"在为LAN使用代理服务器",在"地址"中输入squid服务器的ip地址http://www.jiaochengji.com:

192.168.20.2,在"端口"中输入端口号为:3128单击"确定",然后在IE中输入网址,看是否能访问到网站。

本方法只可浏览网页,不能登陆QQ,下载等。
经本人验证,以上配置是可行的。

您可能感兴趣的文章:
squid代理配置一例
squid3.x透明代理配置详解
squid2.6反向代理实验模型
RHEL5配置Squid透明代理服务器过程解析
squid2.5配置详解+认证
squid反向代理配置(web服务器的前端内容缓存器)
squid2.5安装与配置详解
简单配置squid+iptables的透明代理
清除代理服务器squid上的cache记录
决定squid反向代理的性能要素

[关闭]
~ ~