免费注册 查看新帖 |

Chinaunix

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

[Web] 求救关于apache中的keepalive在虚拟主机中使用 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-06-22 23:15 |只看该作者 |倒序浏览
请问apache中的keepalive可以在虚拟主机中使用吗?
官方上面简绍说可以,但是我在下面的配置中始终不成功。
源码安装2.2.9,
httpd.conf  这个文件只打开了httpd-vhosts.conf这行,其它的都没有变。
[root@localhost httpd-2.2.9]# grep httpd-vhost /usr/local/httpd/conf/httpd.conf  
Include conf/extra/httpd-vhosts.conf
[root@localhost httpd-2.2.9]# tail -18 /usr/local/httpd/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/usr/local/httpd/htdocs"
    ServerName huang2.huang.com
    ErrorLog "logs/huang2-error_log"
    CustomLog "logs/huang2-access_log" common
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/usr/local/httpd/htdocs"
    ServerName huang1.huang.com
    ErrorLog "logs/huang1-error_log"
    CustomLog "logs/huang1-access_log" common
    KeepAlive On
    KeepAliveTimeout 50
</VirtualHost>
在IE用访问huang1.huang.com连刷几次就得到下面的结果。

[root@localhost httpd-2.2.9]# tcpdump -nn dst port 80
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
06:56:16.864013 IP 192.168.11.1.3986 > 192.168.11.11.80: S 2739183246:2739183246(0) win 65535 <mss 1460,nop,nop,sackOK>
06:56:16.866912 IP 192.168.11.1.3986 > 192.168.11.11.80: . ack 1502968652 win 65535
06:56:16.868187 IP 192.168.11.1.3986 > 192.168.11.11.80: P 0:383(383) ack 1 win 65535
06:56:17.112926 IP 192.168.11.1.3986 > 192.168.11.11.80: . ack 190 win 65346
06:56:20.907929 IP 192.168.11.1.3986 > 192.168.11.11.80: P 383:766(383) ack 190 win 65346
06:56:20.993750 IP 192.168.11.1.3986 > 192.168.11.11.80: . ack 378 win 65158
06:56:25.911254 IP 192.168.11.1.3986 > 192.168.11.11.80: . ack 379 win 65158
06:56:27.917782 IP 192.168.11.1.3986 > 192.168.11.11.80: F 766:766(0) ack 379 win 65158
06:56:27.924634 IP 192.168.11.1.3994 > 192.168.11.11.80: S 2041118069:2041118069(0) win 65535 <mss 1460,nop,nop,sackOK>
06:56:27.925631 IP 192.168.11.1.3994 > 192.168.11.11.80: . ack 1512827060 win 65535
06:56:27.929804 IP 192.168.11.1.3994 > 192.168.11.11.80: P 0:383(383) ack 1 win 65535
06:56:28.125682 IP 192.168.11.1.3994 > 192.168.11.11.80: . ack 190 win 65346
06:56:32.940455 IP 192.168.11.1.3994 > 192.168.11.11.80: . ack 191 win 65346
06:56:33.703056 IP 192.168.11.1.3994 > 192.168.11.11.80: R 383:383(0) ack 191 win 0
请问我上面是那里配置错误了吗?

论坛徽章:
0
2 [报告]
发表于 2010-06-23 00:16 |只看该作者
1. KeepAlive 可以用於 vhost 內,請參考:

http://httpd.apache.org/docs/2.2/mod/core.html#keepalive

2. 我不知道你用 tcpdump 能看出啥重點,但是你應該使用 telnet 連結測試就知道。

  1. Linux:kendlee@~> telnet www.google.com 80
  2. Trying 72.14.203.105...
  3. Connected to www.google.com (72.14.203.105).
  4. Escape character is '^]'.
  5. GET / HTTP/1.1
  6. Host: www.google.com

  7. HTTP/1.1 302 Found
  8. Location: http://www.google.com.tw/
  9. Cache-Control: private
  10. Content-Type: text/html; charset=UTF-8
  11. Set-Cookie: PREF=ID=2e766d02f211b629:TM=1277223274:LM=1277223274:S=Ew_VBVY4oGJ6T5X7; expires=Thu, 2                                                          1-Jun-2012 16:14:34 GMT; path=/; domain=.google.com
  12. Set-Cookie: NID=36=WoOh3NfVwtLJmDIi-2ARle2mbS8XyjBKitKsErvC4Xs9XH1IFf3EO__OGtsrPXmHuuMcK218o2WP6kK7                                                          ZtpE7Yxs2pJhL2xXVTG7n8L5Sjsz6Ht7F2fzvPvgHGK4l2my; expires=Wed, 22-Dec-2010 16:14:34 GMT; path=/; do                                                          main=.google.com; HttpOnly
  13. Date: Tue, 22 Jun 2010 16:14:34 GMT
  14. Server: gws
  15. Content-Length: 222
  16. X-XSS-Protection: 1; mode=block

  17. <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
  18. <TITLE>302 Moved</TITLE></HEAD><BODY>
  19. <H1>302 Moved</H1>
  20. The document has moved
  21. <A HREF="http://www.google.com.tw/">here</A>.
  22. </BODY></HTML>
复制代码
測試連結後直接停在那邊,表示 google 支援 KeepAlive,所以一直等下一個動作。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP