Debian 10 上的 Awstats - 访问次数太少 - 修复它的选项

问题描述

我使用 Awstats 多年,在我升级到 Debian 10 之前,一切正常。

我在 Zope 框架后面有一个 Apache2 服务器的特殊配置。我应用 Apache2 的重写规则将请求转发到 Zope。

这里是我对 Apache2 的配置(此文件名为 vhost.conf):

<VirtualHost *:443>

    # Test local
    ServerAdmin henry@example.com
    ServerName example.com
    ServerAlias www.example.com

    # LOG
    CustomLog /var/log/apache2/access.log combined
    #CustomLog /var/log/apache2/access.log common

    # ACTIVATE SSL
    SSLEngine On
    # CONfig FOR LETSENCRYPT
    SSLProtocol -ALL -SSLv3 +TLSv1 +TLSv1.1 +TLSv1.2
    SSLHonorCipherOrder On
    SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    Alias /awstats-icon "/usr/share/awstats/icon"

    RewriteEngine On
    # www to non www for HTTPS
    # checking for the same thing again
    RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
    # some people might argue second redirect here is excessive since you already arrived at correct host,but I'd leave this for you to sort out
    RewriteRule ^/(.*) https://example.com/$1 [R=301,L]
    # your /cgi-bin checks can be merged into one regex
    # See also : https://stackoverflow.com/questions/60732096/awstats-tool-issue-with-missing-icons-and-histogram-bars-on-main-page-of-awsta/61178404#61178404
    RewriteCond %{REQUEST_URI} !^/awstats [NC]
    RewriteCond %{REQUEST_URI} !^/cgi-bin/(search|awstats) [NC]
    RewriteRule ^/(.*)  https://localhost:8443/++vh++https:%{SERVER_NAME}:443/++/$1 [P,L]
    SSLProxyEngine On
    RequestHeader set Front-End-Https "On"
    #Cachedisable *

<Files "awstats.pl">
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        SetHandler cgi-script
        Satisfy any
        Order deny,allow
        Deny from all
        AuthType Basic
        AuthName "Advanced Web Statistics"
        AuthUserFile /etc/apache2/awstats-users.pwd
        Require valid-user
</Files>

<Directory "/usr/share/awstats/icon">
        AllowOverride None
/Files>

<Directory "/usr/share/awstats/icon">
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>

<Directory "/usr/lib/cgi-bin/">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
        SSLRequireSSL
</Directory>

</VirtualHost>

<VirtualHost *:80>

    ServerAdmin henry@example.com
    ServerName example.com
    ServerAlias www.example.com

<IfModule mod_rewrite.c>

    RewriteEngine On
    # Redirect to ww.xx.yy.zz
    RewriteCond %{HTTP_HOST} ^ww\.xx\.yy\.zz
    RewriteRule (.*) http://example2.com$1 [R=301,L]

    # www to non www for HTTP and HTTPS
    RewriteCond %{REQUEST_URI} ^/www\. [NC,OR]
    RewriteCond %{REQUEST_URI} !^/cars/video [NC]
    # Rewrite below works : redirect 80 => https
    RewriteRule ^/(.*) https://example.com/$1 [R=301,L]

    # www to non www for HTTP
    # if you want to keep your `/cars/video` on http check it first
    #RewriteCond %{REQUEST_URI} !^/cars/video [NC]
    RewriteRule ^/(.*)  http://localhost:9674/++vh++http:%{SERVER_NAME}:80/++/$1 [P,L]

</IfModule>

</VirtualHost>

遗憾的是,每日访问量几乎为零:

awstats stats

升级到 Debian 10 之前,我平均每天有 200 次独立访问。

我已将此配置文件包含在“vhost.conf”上方的“/etc/apache2/httpd.conf文件中,如下所示:

# If you prefer a single logfile with access,agent,and referer information
# (Combined Logfile Format) you can use the following directive.
#
CustomLog /var/log/apache2/access.log combined

LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
#LoadModule proxy_ftp_module /usr/lib/apache2/modules/mod_proxy_ftp.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule proxy_connect_module /usr/lib/apache2/modules/mod_proxy_connect.so
#LoadModule authn_alias_module /usr/lib/apache2/modules/mod_authn_alias.so
LoadModule vhost_alias_module /usr/lib/apache2/modules/mod_vhost_alias.so
LoadModule cgid_module /usr/lib/apache2/modules/mod_cgid.so
#LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
LoadModule mime_magic_module /usr/lib/apache2/modules/mod_mime_magic.so
LoadModule cache_module /usr/lib/apache2/modules/mod_cache.so
#LoadModule disk_cache_module /usr/lib/apache2/modules/mod_disk_cache.so
LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
LoadModule PHP5_module libexec/apache2/libPHP5.so
# Get back visitors for awstats
#LoadModule remoteip_module /usr/lib/apache2/modules/mod_remoteip.so

#LogLevel debug
LogLevel alert rewrite:trace3
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T %v" full
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %P %T" debug
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

NameVirtualHost *:80

include vhost.conf

这里可能有什么问题?

顺便说一句,日志文件 access.log 似乎在有访问者时正确填写:我不明白发生了什么。

更新

这里我提供了我当前设置的 awstats.conf 链接

awstats.conf

解决方法

除了允许访问/执行 AWStats CGI(Perl) 脚本的条目外,您发布的所有与 Apache 配置相关的信息似乎都是合理的。您指出正在填充 Apache access.log 的事实让我认为这是 AWStats 配置方式的问题。在 Debian 上,您需要查看文件夹:

/etc/awstats

并找到与您的 Apache vhost 配置匹配的 .conf 文件。确保 .conf 文件正确引用了您的 Apache access.log 文件作为生成统计信息的来源。

其他一些注意事项包括检查 AWStats 是否配置为通过 CRON 例程定期解析您的日志文件,甚至可能根据上述 AWStats 的配置文件按需解析。如果未将其配置为按需运行,则需要实施 CRON 作业以定期解析日志。

不要假设您之前的 AWStats 配置在升级后仍然相关。如果配置不正确,您升级到 Debian 可能会清除您之前的设置。

跟进

基于您发布的 awstats.conf 文件,请确保并使用您期望的所有虚拟主机扩展定义主机别名属性:

HostAliases="localhost 127.0.0.1 REGEX [.com|net|org$]"

不需要 DNS 查找。将此设置为:

DNSLookup=2

然后在您的 Apache conf 文件中,您需要确保允许在您希望访问这些统计信息的目录中执行 AWStats Perl 脚本。您希望 AWStats 可访问的每个虚拟域配置中的这些内容:

# Virtual host container
ScriptAlias /cgi-bin/ /path/to/cgi-bin/
<Directory "/path/to/htdocs/virtual-domain/cgi-bin">
    AllowOverride None
    Options +ExecCGI +SymLinksIfOwnerMatch
    Require all granted
</Directory>

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...