查看apache2的日誌,發現有大量
::1 - - [25/Dec/2009:13:07:51 +0800] "GET / HTTP/1.0" 302 - "-" "Apache/2.2.6 (Unix) PHP/5.2.9 (internal dummy connection)"
查看Apache 官方的說明以下:
"When Apache HTTP Server manages its child processes, it needs a way to wake up processes that are listening for new connections. To do this, it sends a simple HTTP request back to itself... These requests are perfectly normal and you do not, in general, need to worry about them. They can simply be ignored.
原來是http的子進程的緣故,internal dummy connection是由於apache使用了prefork方式,若用worker 則不會使用pop(pipe of death)在進程間通訊,就不會出現internal dummy connections了。
解決的方式:
1. 減少它發生的機會(修改 /etc/apache2/apach2.conf),找到 IfModule mpm_worker_module 這一段:
StartServers 15
MinSpareServers 5
MaxSpareServers 20
MaxClients 150
MaxRequestsPerChild 0
增長 MaxSpareServers 的數量(請依您 server 的連線狀況來作調整),這個能夠減少它發生的機率。可是這個方法不可取,視服務器的配置而定,若過高服務器會down掉。
2. 減少發生還是會發生,因此把這 Request 導到一個固定的網頁:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule ^/$ /blank.html [L]
3. 不要把這資訊寫到 log 裡:
SetEnvIf Remote_Addr "::1" dontlog
CustomLog /var/log/httpd/access.log combined env=!dontlog
屏蔽"::1",能夠過濾字符,不寫入log中。