从一段时间以来(一个月以上),我在apache日志中看到类似以下的行:
180.76.15.138 - - [24/Jun/2015:16:13:34 -0400] "GET /manual/de/mod/module-dict.html HTTP/1.1" 403 396 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" 180.76.15.159 - - [24/Jun/2015:16:28:34 -0400] "GET /manual/es/mod/mod_cache_disk.html HTTP/1.1" 403 399 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" 66.249.75.86 - - [24/Jun/2015:16:18:01 -0400] "GET /manual/es/programs/apachectl.html HTTP/1.1" 403 436 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" [Wed Jun 24 16:13:34.430884 2015] [access_compat:error] [pid 5059] [client 180.76.15.138:58811] AH01797: client denied by server configuration: /usr/share/doc/apache2-doc/manual/de/mod/module-dict.html [Wed Jun 24 16:18:01.037146 2015] [access_compat:error] [pid 2791] [client 66.249.75.86:56362] AH01797: client denied by server configuration: /usr/share/doc/apache2-doc/manual/es/programs/apachectl.html [Wed Jun 24 16:28:34.461298 2015] [access_compat:error] [pid 2791] [client 180.76.15.159:25833] AH01797: client denied by server configuration: /usr/share/doc/apache2-doc/manual/es/mod/mod_cache_disk.html
这些请求似乎确实来自Baiduspider和Googlebot(使用反向DNS进行检查,如此处所述):
user@server:~$ host 66.249.75.86 86.75.249.66.in-addr.arpa domain name pointer crawl-66-249-75-86.googlebot.com. user@server:~$ host crawl-66-249-75-86.googlebot.com crawl-66-249-75-86.googlebot.com has address 66.249.75.86
我已经阅读了类似这个和这个主题的类似问题,但对于这些,这些错误实际上是阻止网站正常工作。 在我的情况下,机器人尝试访问的html页面不存在,因此这是Apache的预期行为。 唯一令人烦恼的是,虽然Google网站pipe理员工具没有显示任何错误,但Google在编制我的网站时似乎很慢。
我正在使用以下vhostconfiguration的Apache版本2.4.7:
<VirtualHost *:80> ServerName example.com ServerAlias www.example.com DocumentRoot "/var/www/example.com/public" <Directory /> Options None AllowOverride None Order Deny,Allow Deny from all Require all denied </Directory> <Directory "/var/www/example.com/public"> Options None AllowOverride FileInfo Limit Options=FollowSymLinks Order Allow,Deny Allow from all Require all granted </Directory> ErrorLog /var/log/apache2/example.com/error.log CustomLog /var/log/apache2/example.com/access.log combined </VirtualHost>
我的问题是:
GET /manual/de/mod/...这样的请求是如何映射到/usr/share/doc/apache2-doc/manual/de/mod/...而我的理解是,他们应该到/var/www/example.com/public/manual/de/mod/... ? 由于一段时间没有任何答案,我决定(部分)根据我的研究回答我自己的问题。
/manual/... URL会映射到/usr/share/doc/apache2-doc/manual/...感谢Ubuntu上的预安装Alias:我想这是为了方便访问文档。 在我的情况下,这是不需要的,所以我决定通过发出a2disconf apache2-doc然后service apache2 reload来删除别名。 在2.2中,基于客户端主机名,IP地址和客户端请求的其他特征的访问控制是通过Order,Allow,Deny和Satisfy指令完成的。
在2.4中,这种访问控制与其他授权检查相同,使用新模块mod_authz_host。 旧的访问控制成语应该被新的authentication机制所取代 ,尽pipe为了与旧的configuration兼容,提供了新的模块mod_access_compat。
看起来你已经设置了新的Require指令,所以只需删除已弃用的访问指令并运行sudo service apache2 reload