我正在更新一些旧的AWStats配置文件,以过滤掉一些特定的IP范围。这是配置文件的相关部分:

# Do not include access from clients that match following criteria.
# If your log file contains IP addresses in host field, you must enter here
# matching IP addresses criteria.
# If DNS lookup is already done in your log file, you must enter here hostname
# criteria, else enter ip address criteria.
# The opposite parameter of "SkipHosts" is "OnlyHosts".
# Note: Use space between each value. This parameter is not case sensitive.
# Note: You can use regular expression values writing value with REGEX[value].
# Change : Effective for new updates only
# Example: "127.0.0.1 REGEX[^192\.168\.] REGEX[^10\.]"
# Example: "localhost REGEX[^.*\.localdomain$]"
# Default: ""
#
SkipHosts=""

我想,例如,过滤掉X.Y.Z. [97-110]

我尝试了这种格式(注意:不是这些IP值,使用私有范围作为示例):

REGEX[^192\.168\.1\.[97-110]]

但它会导致以下错误:

  

CGI错误
指定的CGI   应用程序行为不端   返回一整套HTTP   头。

我讨厌一切都使用不同的RegEx语法。有没有人知道这个是如何工作的,以及我如何在这里指定一个范围?

有帮助吗?

解决方案

假设REGEX []中支持字符类:

SkipHosts = "REGEX[^192\.168\.1\.(9[7-9]|10[0-9]|110)$]"

其他提示

你使用的正则表达式指定9或7到1或1或0混乱。

您可以使用

SkipHosts="REGEX[^192\.168\.1\.(97|98|99|100|101|102|103|104|105|106|107|108|109|110)]"

如果你这么倾向

如果你将SkipHosts留空,AWStats会运行吗?否则,请尝试使用命令行实用程序检查错误。例如,使用Windows:

c:\perlpath\perl.exe awstats.pl config=yourconfigfile -update -logfile=yourlogfile

这应该提供更多细节。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top