免费注册 查看新帖 |

Chinaunix

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

求助squid+apache,详细配置说明 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-09-25 17:52 |只看该作者 |倒序浏览
小弟初始接触 squid  听说这代理可以加速动态网页,并可以解决apache的负载问题,

在网上收集了不少资料, 但是今天配置了一下,尝未成功. 所以请各位朋友帮助,或给个详细的配置方法,谢谢!

我的版本配置方法如下

squid-2.6.STABLE16-1.fc7

httpd-2.2.4-4.1.fc7

httpd.conf 端口有80改为8080 测试正常, 所以apache 没有问题,

squid.conf 配置如下

  1. acl all src 0.0.0.0/0.0.0.0
  2. acl manager proto cache_object
  3. acl localhost src 127.0.0.1/255.255.255.255
  4. acl to_localhost dst 127.0.0.0/8
  5. acl SSL_ports port 443
  6. acl Safe_ports port 8080        # http
  7. acl Safe_ports port 443                # https
  8. acl Safe_ports port 1025-65535        # unregistered ports
  9. acl CONNECT method CONNECT

  10. acl apache rep_header Server ^Apache
  11. broken_vary_encoding allow apache
  12. collapsed_forwarding on

  13. http_access deny all
  14. http_access allow manager localhost
  15. http_access deny manager
  16. http_access deny !Safe_ports
  17. http_access deny CONNECT !SSL_ports
  18. http_access allow localhost
  19. http_access deny all
  20. http_reply_access allow all
  21. icp_access deny all

  22. http_port 80

  23. reply_header_max_size= 4000 KB
  24. reply_body_max_size 0 allow all

  25. acl QUERY urlpath_regex cgi-bin \?
  26. cache deny QUERY
  27. cache_mem 16 MB
  28. maximum_object_size_in_memory 8 KB
  29. cache_replacement_policy lru
  30. cache_dir ufs /home/cache 10000 16 256
  31. max_open_disk_fds 0
  32. minimum_object_size 0 KB
  33. maximum_object_size 8192 KB
  34. cache_swap_low 80
  35. cache_swap_high 85
  36. access_log /var/log/squid/access.log squid
  37. cache_log /var/log/squid/cache.log
  38. cache_store_log /var/log/squid/store.log
  39. cache_mgr [email]sky@test.com[/email]
  40. cache_effective_user squid
  41. cache_effective_group squid

  42. emulate_httpd_log on
  43. mime_table /etc/squid/mime.conf
  44. log_mime_hdrs off
  45. pid_filename /var/run/squid.pid
  46. client_netmask 255.255.255.0

  47. vary_ignore_expire on
  48. request_entities on

  49. httpd_suppress_version_string on
  50. visible_hostname 192.168.18.199
  51. hostname_aliases 192.168.18.199
  52. httpd_accel_no_pmtu_disc on

  53. #dns_nameservers 10.0.0.1 192.172.0.4
  54. append_domain .yourdomain.com

  55. ignore_unknown_nameservers on

  56. client_db on
  57. max_filedesc 2048
复制代码


squid -z 没有错误,
service squid restart 重启没有错误,

好了到IE浏览器 输入 http://192.168.18.199 时候出现如下错误


  1. ERROR
  2. The requested URL could not be retrieved

  3. --------------------------------------------------------------------------------

  4. While trying to process the request:

  5. GET / HTTP/1.1
  6. Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
  7. Accept-Language: zh-cn
  8. UA-CPU: x86
  9. Accept-Encoding: gzip, deflate
  10. User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Mozilla/4.0(Compatible Mozilla/4.0(Compatible-EmbeddedWB 14.59 [url]http://bsalsa.com/[/url] EmbeddedWB- 14.59  from: [url]http://bsalsa.com/[/url] ; Mozilla/4.0(Compatible Mozilla/4.0EmbeddedWB- 14.59  from: [url]http://bsalsa.com/[/url] ; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
  11. Host: 192.168.18.199
  12. Connection: Keep-Alive


  13. The following error was encountered:

  14. Invalid Request
  15. Some aspect of the HTTP Request is invalid. Possible problems:

  16. Missing or unknown request method
  17. Missing URL
  18. Missing HTTP Identifier (HTTP/1.0)
  19. Request is too large
  20. Content-Length missing for POST or PUT requests
  21. Illegal character in hostname; underscores are not allowed
  22. Your cache administrator is [email]sky@test.com[/email].

  23. --------------------------------------------------------------------------------

  24. Generated Tue, 25 Sep 2007 09:49:25 GMT by 192.168.18.199 (squid/2.6.STABLE16)
复制代码


这证明了squid 起到了作用,但是为什么打不开里面的网站内容

如输入 http://192.168.18.199:8080 即正常,因为这是直接连接到apache 服务里,并没用到代理,

所以请各位帮忙一下,

论坛徽章:
0
2 [报告]
发表于 2007-09-25 17:59 |只看该作者
还有一点,如果加上如下,
httpd_accel_host 127.0.0.1
httpd_accel_port 8080                   #apache的端口
httpd_accel_single_host on
httpd_accel_with_proxy on          #启用缓存
httpd_accel_uses_host_header on #启用虚拟主机支持
说没有httpd_accel这语法, 但是在squid 2.5测试一下,这是OK的,不知道是不是版本问题,

论坛徽章:
0
3 [报告]
发表于 2007-09-25 23:34 |只看该作者
没有人回自已顶上:wink:

论坛徽章:
0
4 [报告]
发表于 2007-09-26 09:07 |只看该作者
你看下日志,先确定squid有没有向源web服务器请求数据。

论坛徽章:
0
5 [报告]
发表于 2007-09-26 10:48 |只看该作者

回复 #4 qqeyes 的帖子

好明天上班再测试一下, 请问你有没有配置过, 如果配置过,能问分享一下.

论坛徽章:
0
6 [报告]
发表于 2007-09-26 11:03 |只看该作者
原帖由 luo118 于 2007-9-25 17:52 发表
小弟初始接触 squid  听说这代理可以加速动态网页,并可以解决apache的负载问题,

在网上收集了不少资料, 但是今天配置了一下,尝未成功. 所以请各位朋友帮助,或给个详细的配置方法,谢谢!

我的版本配置方法如 ...

是否做了对apahce8080端口的访问跳转到squid 80端口访问的设置
例如iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 8080 -j REDIRECT --to-ports 80
具体可根据自己情况来定

论坛徽章:
0
7 [报告]
发表于 2007-09-26 13:14 |只看该作者

回复 #6 xuledw 的帖子

楼上, 我上面直接用了80端口给了squid用了,应不用NAT转换了吧!
因为我根本没有8080访问的,只是测试,
80已经给squid用了,所以不用做NAT转换,

除非apache用80 squid用8080 那么NAT为
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP