如何在AWSStats配置文件中为SkipHosts指定IP范围(RegEx)?
时间:2020-03-06 14:58:47 来源:igfitidea点击:
我正在更新一些旧的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 Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.
我讨厌一切都使用不同的RegEx语法。有谁知道这是如何工作的,以及如何在此处指定范围?
解决方案
如果将SkipHosts保留为空,AWStats是否运行?否则,请尝试使用命令行实用程序来检查错误。例如,使用Windows:
c:\perlpath\perl.exe awstats.pl config=yourconfigfile -update -logfile=yourlogfile
那应该给出更多细节。
假设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)]"
如果你这么倾向