环境

Squid server:

IP:

eth0 192.168.77.222

eth1 192.168.7.222

Squid.conf:

http_port 192.168.7.222:80 vport vhost

cache_peer 192.168.77.225 parent 80 0 no-query originserver weight=1 name=b

cache_peer 192.168.77.221 parent 80 0 no-query originserver weight=2 name=a

cache_peer_domain a www.test1.com

cache_peer_domain b www.test2.com

cache_peer_access a allow all

cache_peer_access b allow all

client:

IP:

eth0 192.168.7.223

Apache server1:

192.168.7.221 index.html:This is Apache server1 .My IP is 192.168.7.221

Apache server2:

192.168.7.225 index.html:This is Apache server2 .My IP is 192.168.7.225

实际应用中遇到的问题:

今天在试验中遇到一个很奇怪的问题,我在client地址栏中输入:

www.test1.com 显示:This is Apache server1 .My IP is 192.168.7.221

www.test2.com 显示:This is Apache server2 .My IP is 192.168.7.225

192.168.7.222 显示:This is a test!(我以前测试时候写的内容,但是早都已经删除了)

很郁闷,想Google也没办法google。没办法,只能自己来。

思路:

1. 首先我想着是不是squid.conf文件是否错误。

a) 经过仔细检查后派出配置文档错误

2. 检查Apache服务是否启动

因为我的代理端口端口时80,所以Apache服务早都已经挺了,可以说不用考虑的。但是苦于无法只能又检查一遍

b)确定不是本机Apache的问题

3. 检查/var/www/html/index.html

c)分别检查了squid server和两台Apache server index.html文件压根就没有This is a test!这句话,很是郁闷。

4. 出绝招了.

不是办法的办法.从根/ 下搜包含This is a test!这句话的文件,只要找到了这句话所在的文件,就知道问题所在了.

d)grep ‘This is a test!’ / =========== 无果而终 ~_~

5. 后来突然发现可能是cache没有清! 激动

e)# ./squidclient -h 192.168.7.222 -p 80 PURGEA http://192.168.7.222

HTTP/1.0 200 OK

Date: Tue, 06 Jul 2010 21:04:16 GMT

Server: Apache/2.2.3 (CentOS)

Last-Modified: Mon, 05 Jul 2010 17:47:10 GMT

ETag: "10e03ab-10-86a56380"

Accept-Ranges: bytes

Content-Length: 16

Content-Type: text/html; charset=UTF-8

Age: 94967

Warning: 113 song.domain.com (squid/3.1.4) This cache hit is still fresh and more than 1 day old

X-Cache: HIT from song.domain.com

Via: 1.0 song.domain.com (squid/3.1.4)

Connection: close

This is a test!

终于被我逮到了(但是我刚才从根/开始搜索的时候为什么没有结果呢?),再到client测试

满怀期待,还是无果而终,还是This is a test!.

郁闷啊!那个郁闷,还真的没折了.

俗话说成功只在一步之遥!哈哈,

6. 成功进行曲最后一步:

f) 最后索性直接跑到cache目录下/usr/local/squid/var/cache/00/00

#grep 'this is a test' ./*

Binary file ./00000000 matches

Binary file ./00000001 matches

Binary file ./00000002 matches

但是刚才的命令为什么没有清掉呢!?…………………….探索…………………………..

Caches caches 都是caches惹的祸!!索性一股脑把文件夹下的cache全部删除了。再到client ok 问题解决。哈哈 =_=