免费注册 查看新帖 |

Chinaunix

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

[proxy] squid 代理无法访问google (问题解决过程) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-04-12 15:13 |只看该作者 |倒序浏览
squid一直使用正常,今天出现怪现象:
访问www.google.com
squid 返回:

ERROR
The requested URL could not be retrieved


--------------------------------------------------------------------------------

While trying to retrieve the URL: http://www.google.com/intl/zh-CN

The following error was encountered:

Connection Failed
The system returned:

    (110) Connection timed outThe remote host or network may be down. Please try the request again.
Your cache administrator is root.

做了如下测试
1.在squid服务器上,nslookup得到www.google.com的IP.使用http://googleIP 访问正常.

2.使用http://www.google.com方式访问,在access.log中得到如下信息:
172.28.88.6 - - [12/Apr/2006:15:07:30 +0800] "GET http://www.google.com/intl/zh-CN HTTP/1.0" 504 1353 TCP_MISS:NONE

3.访问 http://www.google.com.cn ,可以正常访问.

4.访问http://www.google.co.jp ,  可以正常访问.
为何访问http://www.google.com 就不能访问呢? ....
squid cache 的原因?

大家帮忙看看吧..

[ 本帖最后由 fengwenzi 于 2006-4-17 11:51 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2006-04-13 09:08 |只看该作者
考虑到可能是squid cache的关系
将squid cache全部清除,重新建立cache,访问www.google.com.问题仍然存在.

access.log 中这条记录:
172.28.88.6 - - [12/Apr/2006:15:07:30 +0800] "GET http://www.google.com/intl/zh-CN HTTP/1.0" 504 1353 TCP_MISS:NONE
日志分析:
TCP_MISS: 可以确定上述request 没有存在于cache中.
http status code 返回504,表示gateway timeout.
可能是网络有问题?

做如下测试:
从squid服务器上使用dig 测试:

dig www.google.com
; <<>> DiG 9.2.4 <<>> www.google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37235
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 6, ADDITIONAL: 6

;; QUESTION SECTION:
;www.google.com.                IN      A

;; ANSWER SECTION:
www.google.com.    523077       IN      CNAME   www.l.google.com.

www.l.google.com.  98   IN      CNAME   www-china.l.google.com.
www-china.l.google.com. 53      IN      A       66.249.89.99


使用IE测试:
1.访问:http://www.l.google.com ,可以正常访问.
2.访问:http://www-china.l.google.com ,可以正常访问.
3.访问:http://66.249.89.99 ,可以正常访问.

那么,DNS可以解析到google.com.为什么google的CNAME都可以访问,但www.google.com 不行?

[ 本帖最后由 fengwenzi 于 2006-4-13 09:49 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2006-04-13 11:36 |只看该作者
你好,我用 squid 测试了一下,没有发现问题,你去掉所有 http_access deny 还有这个问题么?

论坛徽章:
0
4 [报告]
发表于 2006-04-13 14:13 |只看该作者
原帖由 jiawj 于 2006-4-13 11:36 发表
你好,我用 squid 测试了一下,没有发现问题,你去掉所有 http_access deny 还有这个问题么?


这个不是acl 限制的问题..

谢谢jiawj回复.

论坛徽章:
0
5 [报告]
发表于 2006-04-17 12:16 |只看该作者

回复 4楼 fengwenzi 的帖子

谢谢坛子里的朋友的关注,现在问题已经解决.
下面我把最后的解决方法贴出来,希望对以后遇到类似问题的朋友有所帮助:

1.其实如果大家仔细看看上面我贴出来的错误信息,大家一定大多以为问题应该出现在DNS解析上:
2.因为使用IP地址可以访问google.但使用域名就不行.
3.但NSLOOKUP测试,可以确定DNS解析没有问题.
4.在squid服务器上:squidclient -p80 http://www.google.com ,返回alarm clock.而使用telnet www.google.com 80 .可以正常get 到页面.可以排除网络问题.
5.仔细考虑了一下squid+DNS的解析过程,才发现自己乎略了一个细节.就是hosts 文件.
6.原来自己在hosts文件里设置了IP-> www.google.com 的对应关系.squid 在响应一个请求时,它首先会去squid服务器的hosts文件里查找对应记录.如果存在,就不在使用DNS查询而直接转到对应的IP地址.
7.问题就出现在hosts文件里有一条IP ->www.google.com 的记录无法访问到.才出现上述http 返回代码504的错误..
8.将hosts文件里的IP记录删除.问题解决.

论坛徽章:
0
6 [报告]
发表于 2006-04-17 15:13 |只看该作者

回复 5楼 fengwenzi 的帖子

您所说的hosts文件是指系统的hosts文件(/etc/hosts)吗?

论坛徽章:
0
7 [报告]
发表于 2006-04-17 15:15 |只看该作者
是这个吗?
  1. #  TAG: hosts_file
  2. #       Location of the host-local IP name-address associations
  3. #       database.  Most Operating Systems have such a file: under
  4. #       Un*X it's by default in /etc/hosts.  MS-Windows NT/2000 places
  5. #       it in %SystemRoot%(by default
  6. #       c:\winnt)\system32\drivers\etc\hosts, while Windows 9x/ME
  7. #       places it in %windir%(usually c:\windows)\hosts
  8. #
  9. #       The file contains newline-separated definitions, in the
  10. #       form ip_address_in_dotted_form name [name ...] names are
  11. #       whitespace-separated.  lines beginning with an hash (#)
  12. #       character are comments.
  13. #
  14. #       The file is checked at startup and upon configuration.  If
  15. #       set to 'none', it won't be checked.  If append_domain is
  16. #       used, that domain will be added to domain-local (i.e. not
  17. #       containing any dot character) host definitions.
  18. #
  19. #Default:
  20. # hosts_file /etc/hosts
复制代码

可是我的squid.conf里头没设呀,那就是/etc/hosts了

论坛徽章:
0
8 [报告]
发表于 2006-04-17 15:36 |只看该作者
原帖由 ljily000 于 2006-4-17 15:13 发表
您所说的hosts文件是指系统的hosts文件(/etc/hosts)吗?


对,就是/etc/hosts文件
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP