Apache 内部虚拟连接

Apache 内部虚拟连接

我正在对 Apache 进行一些负载测试,并收到大量内部虚拟连接

::1 219 - [22/Dec/2011:11:02:57 +0000] "OPTIONS * HTTP/1.0" 200 181 "-" "Apache (internal dummy connection)"
::1 221 - [22/Dec/2011:11:02:58 +0000] "OPTIONS * HTTP/1.0" 200 181 "-" "Apache (internal dummy connection)"
::1 188 - [22/Dec/2011:11:02:59 +0000] "OPTIONS * HTTP/1.0" 200 181 "-" "Apache (internal dummy connection)"
::1 243 - [22/Dec/2011:11:03:03 +0000] "OPTIONS * HTTP/1.0" 200 181 "-" "Apache (internal dummy connection)"
::1 215 - [22/Dec/2011:11:03:04 +0000] "OPTIONS * HTTP/1.0" 200 181 "-" "Apache (internal dummy connection)"
::1 178 - [22/Dec/2011:11:03:05 +0000] "OPTIONS * HTTP/1.0" 200 181 "-" "Apache (internal dummy connection)"

这是虚拟主机配置:

NameVirtualHost *:80
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^.*internal dummy connection.*$ [NC]
RewriteRule ^/$ /blank.html [L]

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/vhosts/domain/html
    ServerName domain
    ErrorLog /var/www/vhosts/domain/error_log
    SetEnvIf REMOTE_ADDR "(.+)" CLIENTIP=$1
    SetEnvIf X-Forwarded-For "^([0-9.]+)" CLIENTIP=$1
    LogFormat "%{CLIENTIP}e %D %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" trueip_combined
    CustomLog "/var/www/vhosts/domain/access_log" trueip_combined
<Directory /var/www/vhosts/domain/html>
Options -Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Order allow,deny
               Allow from all
</Directory>
</VirtualHost>

为了解决这个问题,我使用重写规则将所有内部虚拟连接重新重定向到 blank.html,但它给出了语法错误?

[root@ip-10-56-1-98 ~]# /etc/init.d/httpd configtest
Syntax error on line 3 of /etc/httpd/conf.d/vhosts.conf:
RewriteCond: bad flag delimiters

有任何想法吗?

答案1

您需要转义以下空格:

RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]

答案2

对我有用的解决方案

代替

CustomLog "logs/access_log" combined

SetEnvIf Remote_Addr "::1" loopback
SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
CustomLog logs/access_log combined env=!loopback

来源

相关内容