免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2166 | 回复: 0
打印 上一主题 下一主题

[proxy] 简单的squid配置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-03-03 11:07 |只看该作者 |倒序浏览
本试验参照
http://bbs.linuxpk.com/thread-28845-1-1.html

经本人验证,可行


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


服务端两块网卡
外网网卡eth0,IP:121.15.134.2
内网网卡eth1,IP:192.168.20.2/24

1.[root@localhost ~]# 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就可以了。

本试验直接初始化通过
[root@localhost ~]# squid -z



3.[root@localhost ~]# ls /var/spool/squid/
00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F  swap.state

启动squid服务
[root@localhost ~]# service squid start



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

找到如下行:
http_port 3128
把它修改为:
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, 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地址:192.168.20.2,在"端口"中输入端口号为:3128单击"确定",然后在IE中输入网址,看是否能访问到网站


本方法只可浏览网页,不能登陆QQ,下载等
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP