apache httpd 不断向陌生的 IP 发送 http 请求

sma*_*ufo 2 security mod-rewrite mod-proxy rewritecond apache-2.2

最近我注意到我的服务器通过netstat -na.

为了找出它发送的内容,我尝试了:

tcpdump -i eth0 host 121.11.76.48 -nnvvXSs 1514
Run Code Online (Sandbox Code Playgroud)

并发现它不断向此位置发送 HTTP 请求:

22:55:21.179353 IP (tos 0x0, ttl  64, id 26103, offset 0, flags [DF], proto: TCP (6), length: 296) 192.168.1.13.58155 > 121.11.76.48.80: P, cksum 0x880b (incorrect (-> 0xd884), 1904784743:1904784999(256) ack 915059568 win 46
    0x0000:  4500 0128 65f7 4000 4006 4ce8 c0a8 010d  E..(e.@.@.L.....
    0x0010:  790b 4c30 e32b 0050 7188 b567 368a b370  y.L0.+.Pq..g6..p
    0x0020:  5018 002e 880b 0000 4745 5420 2f20 4854  P.......GET./.HT
    0x0030:  5450 2f31 2e31 0d0a 486f 7374 3a20 0d0a  TP/1.1..Host:...
    0x0040:  4163 6365 7074 3a20 2a2f 2a0d 0a52 6566  Accept:.*/*..Ref
    0x0050:  6572 6572 3a20 6874 7470 3a2f 2f77 7777  erer:.http://www
    0x0060:  2e78 6264 796d 2e63 6f6d 2f69 6e64 6578  .xbdym.com/index
    0x0070:  2e61 7370 0d0a 4163 6365 7074 2d4c 616e  .asp..Accept-Lan
    0x0080:  6775 6167 653a 207a 682d 636e 0d0a 4163  guage:.zh-cn..Ac
    0x0090:  6365 7074 2d45 6e63 6f64 696e 673a 2067  cept-Encoding:.g
    0x00a0:  7a69 702c 2064 6566 6c61 7465 0d0a 5573  zip,.deflate..Us
    0x00b0:  6572 2d41 6765 6e74 3a20 4d6f 7a69 6c6c  er-Agent:.Mozill
    0x00c0:  612f 342e 3020 2863 6f6d 7061 7469 626c  a/4.0.(compatibl
    0x00d0:  653b 204d 5349 4520 362e 303b 2057 696e  e;.MSIE.6.0;.Win
    0x00e0:  646f 7773 2035 2e31 290d 0a50 7261 676d  dows.5.1)..Pragm
    0x00f0:  613a 206e 6f2d 6361 6368 650d 0a56 6961  a:.no-cache..Via
Run Code Online (Sandbox Code Playgroud)

显然,我的服务器中的某些内容使用 IE6 浏览器不断向 www.xbdym.com(即 121.11.76.48)发送数据包(大约一个数据包/秒)!

但是,我的盒子是 linux 盒子(CentOS 5.6),无法在其上运行 IE6。而且我没有安装任何 Windows VM。

然后,我用lsof -i找哪个进程发送数据包!

httpd   13232 apache   20u  IPv4 326404481       TCP 192.168.1.13:48988->121.11.76.48:http (ESTABLISHED)
Run Code Online (Sandbox Code Playgroud)

它是阿帕奇!很奇怪,为什么 apache 如此频繁地向这个位置发送数据包?

然后我深入 apache 的日志并在 access_log 中找到了很多记录:

121.11.80.126 - - [23/Dec/2011:22:58:58 +0800] "GET http://www.xbdym.com HTTP/1.1" 502 495 "http://www.xbdym.com/index.asp"
 "Mozilla/4.0 (compatible; MSIE 6.0; Windows 5.1)"
Run Code Online (Sandbox Code Playgroud)

并在 rewrite.log 中:

121.11.80.126 - - [23/Dec/2011:23:05:57 +0800] [www.xbdym.com/sid#2b1de9435be0][rid#2b1df49d6ad0/initial] (1) pass through proxy:http://www.xbdym.com
Run Code Online (Sandbox Code Playgroud)

我的服务器是否充当代理?事实上,直接连接到我的服务器被重定向到我的内部 java 服务器(由 ProxyPass 和 ProxyPassReserve 设置),我设置了这个:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^myserver.com
RewriteLog "/home/myserver/log/rewrite.log"
RewriteLogLevel 1
Run Code Online (Sandbox Code Playgroud)

那里有一个“ RewriteCond”,不以“myserver.com”开头的主机不应该通过!但是它是如何通过我的代理的!?还有,怎么阻止!?

环境:

httpd-2.2.3-53.el5.centos.3
CentOS 5.6
2.6.18-238.12.1.el5xen
Run Code Online (Sandbox Code Playgroud)

- 更新 -

我的 ProxyPass 设置:

ProxyPreserveHost on
ProxyPass        /app http://localhost:8080/app
ProxyPassReverse /app http://localhost:8080/app
Run Code Online (Sandbox Code Playgroud)

Lad*_*ada 5

RewriteCond线仅影响下RewriteRule被处理。它自己什么都不做。

由于RewriteRule在您提供给我们的配置片段中没有遵循它,我最好的猜测是它RewriteCond什么都不做。

应该阻止任何不发送正确Host:标头的快速更改:

RewriteCond %{HTTP_HOST} !^myserver.com
RewriteRule - - [F]
Run Code Online (Sandbox Code Playgroud)

你对所见所闻的分析对我来说似乎是正确的;您的 Apache 配置为开放中继。

您的 ProxyPass 和 ProxyPassReverse 行是什么样的?(我假设您实际上是在 Apache 配置中编写了 ProxyPassReverse 而不是 ProxyPassReserve。)

我注意到请求发送了一个Host:非常奇怪的空标头。我怀疑您的 VirtualHost 被配置为默认值,这意味着它会处理所有请求,即使Host:标头与ServerNameServerAlias变量不匹配。

有一些关于如何在Apache wiki 中添加额外的、非代理的默认 VirtualHost 的建议。而且,为了完整起见,这里有一个指向mod_proxy 文档的链接。