寻觅生命中的那一片浅草......

RHEL5下的Squid

squid装好后,就可以启动了,但其他电脑还不能直接通过这个代理来上网,配置文件里只允许localhost使用这个代理,感觉默认配置文件有点不合理,如果只给本机代理上网,根本没什么意义,或者本机通过本机的代理上网这样更加安全吧?

当你不修改squid.conf,启动squid后,你在另外一台电脑修改浏览器的代理设置,你会得到以下提示

ERROR
The requested URL could not be retrieved

While trying to retrieve the URL: http://www.baidu.com/

The following error was encountered:
Access Denied.

Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.

Your cache administrator is root.



下面介绍下我的简单配置
1、安装
#rpm -ivh squid-2.6.STABLE6-3.el5.i386.rpm

2、修改/etc/squid/squid.conf,将以下行
#acl our_networks src 192.168.1.0/24 192.168.2.0/24
#http_access allow our_networks
修改为:
acl our_networks src 192.168.1.0/24
http_access allow our_networks

其中192.168.1.0/24为我的本地网络网段,请根据你自己的网段作相应修改,如果你想其他人,例如外网的电脑也可以访问你的代理服务器,你需要做一个3128端口(squid的默认监听端口)的NAT,然后将配置文件下的以下行
http_access deny all
修改为:
http_access allow all

3、create swap directories
#squid -z

4、启动
#service squid start

5、测试是否已经在运行
#netstat -tln | grep 3128
如出现以下行,则表明squid已经正常工作
tcp        0      0 0.0.0.0:3128                0.0.0.0:*                   LISTEN

6、在另外一台电脑设置代理
ip地址和端口填代理服务器的IP地址192.168.1.100和监听端口3128

OK了,已经可以通过代理上网冲浪了,当然了,这只是最简单的配置,有时间再研究下深入的配置.

7、其他命令
# squid -k reconfig #重新读取配置文件

尚无评论

发表评论

2024年四月
« 5月    
1234567
891011121314
15161718192021
22232425262728
2930