1

我使用 Apache 2.2.25 和 cpanel 中的错误日志进行托管。

我每小时收到大约 20/30 次此错误,该站点似乎可以正常加载而没有问题(据我所知),但是根据错误肯定存在问题。你对这个错误有什么预感?

以下是错误:

[2013 年 9 月 9 日星期一 12:56:20] [错误] [客户端 123.45.6.78] 客户端被服务器配置拒绝:/home/public_html/404.php [2013 年 9 月 9 日星期一 12:56:20] [错误] [客户端123.45.6.78] 客户端被服务器配置拒绝:/home/public_html/blog/article

粗线表示具有 IP 地址的人访问了一个文件(一篇博客文章),但此后他们似乎看到了 404 页面。奇怪的是,如果我亲自访问他们查看的那个页面,它加载得很好......

我想我的问题是 - 如果您遇到此错误,您是如何解决的?

所引用的建议答案建议将语法更改为:

<Location />
Allow from all
Order Deny,Allow
</Location>

以上内容是否适用于每个目录或位置,即我会直接在下面删除“文件 .htaccess”?

<files .htaccess>
Order allow,deny
Deny from all
</files>


# Prevent hotlinking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?my-site.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]

# 5G:[QUERY STRINGS]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (\"|%22).*(<|>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (javascript:).*(\;) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (\\|\.\./|`|=\'$|=%27$) [NC,OR]
RewriteCond %{QUERY_STRING} (\;|\'|\"|%22).*     (union|select|insert|drop|update|md5|benchmark|or|and|if) [NC,OR]
RewriteCond %{QUERY_STRING} (base64_encode|localhost|mosconfig) [NC,OR]
RewriteCond %{QUERY_STRING} (boot\.ini|echo.*kae|etc/passwd) [NC,OR]
RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC]
RewriteRule .* - [F]
</IfModule>

# 5G:[USER AGENTS]
<IfModule mod_setenvif.c>
# SetEnvIfNoCase User-Agent ^$ keep_out
SetEnvIfNoCase User-Agent     (binlar|casper|cmsworldmap|comodo|diavol|dotbot|feedfinder|flicky|ia_archiver|jakarta|kmccrew|nutch|planetwork|purebot|pycurl|skygrid|sucker|turnit|vikspider|zmeu) keep_out
<limit GET POST PUT>
Order Allow,Deny
Allow from all
Deny from env=keep_out
</limit>
</IfModule>

# 5G:[REQUEST STRINGS]
<IfModule mod_alias.c>
RedirectMatch 403 (https?|ftp|php)\://
RedirectMatch 403 /(https?|ima|ucp)/
RedirectMatch 403 /(Permanent|Better)$
RedirectMatch 403 (\=\\\'|\=\\%27|/\\\'/?|\)\.css\()$
RedirectMatch 403 (\,|\)\+|/\,/|\{0\}|\(/\(|\.\.\.|\+\+\+|\||\\\"\\\")
RedirectMatch 403 \.(cgi|asp|aspx|cfg|dll|exe|jsp|mdb|sql|ini|rar)$
RedirectMatch 403 /(contac|fpw|install|pingserver|register)\.php$
RedirectMatch 403 (base64|crossdomain|localhost|wwwroot|e107\_)
RedirectMatch 403 (eval\(|\_vti\_|\(null\)|echo.*kae|config\.xml)
RedirectMatch 403 \.well\-known/host\-meta
RedirectMatch 403 /function\.array\-rand
RedirectMatch 403 \)\;\$\(this\)\.html\(
RedirectMatch 403 proc/self/environ
RedirectMatch 403 msnbot\.htm\)\.\_
RedirectMatch 403 /ref\.outcontrol
RedirectMatch 403 com\_cropimage
RedirectMatch 403 indonesia\.htm
RedirectMatch 403 \{\$itemURL\}
RedirectMatch 403 function\(\)
RedirectMatch 403 labels\.rdf
RedirectMatch 403 /playing.php
RedirectMatch 403 muieblackcat
</IfModule>

# 5G:[REQUEST METHOD]
<ifModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>

# 5G:[BAD IPS]
# <limit GET POST PUT>
# Order Allow,Deny
# Allow from all
# uncomment/edit/repeat next line to block IPs
# Deny from 123.456.789
# </limit>

ErrorDocument 400 http://www.my-site.com/404.php
ErrorDocument 401 http://www.my-site.com/404.php
ErrorDocument 403 http://www.my-site.com/404.php
ErrorDocument 404 http://www.my-site.com/404.php
ErrorDocument 500 http://www.my-site.com/404.php

</code>
4

1 回答 1

0

首先检查您的 apache 版本,Order allow,deny并且Allow from all不再适用于 apache 2.4。

要查看以何种顺序应用了哪些指令,请查看此文档页面,您会发现Location指令是在Files指令之后应用的,因此Location /不应覆盖.htaccess访问的 403(但要对其进行测试)。

然后,你有很多安全检查规则,甚至403页面都重定向到404.php。因此,日志行很可能"configuration: /home/public_html/404.php [Mon Sep 09 12:56:20 2013] [error] [client 123.45.6.78] client denied by server configuration: /home/public_html/blog/article"是针对包含您的任何5G规则(机器人、禁止的 url 参数、禁止的请求方法)的请求。您可以在日志中添加更多信息以进行检查,但请注意之后用于读取日志的工具(以免激活日志注入)。

是可以添加到日志中的内容列表。您可以%m为方法、%H协议、%q查询参数添加,如表中所述,您也可以%!200,304,302{Referer}i为引用者添加,但仅限于无效的响应等。

于 2013-09-10T16:06:05.883 回答