Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Awstats工具:Awstats主页上缺少图标和直方图条的问题-可能是Apache中定义的路径问题_Apache_Url Rewriting_Icons_Cgi_Awstats - Fatal编程技术网

Awstats工具:Awstats主页上缺少图标和直方图条的问题-可能是Apache中定义的路径问题

Awstats工具:Awstats主页上缺少图标和直方图条的问题-可能是Apache中定义的路径问题,apache,url-rewriting,icons,cgi,awstats,Apache,Url Rewriting,Icons,Cgi,Awstats,在我的一个名为website.com的网站上,我很难用awstats工具CGI脚本、图标和相关的直方图条显示 这个问题相当棘手,因为我使用不同的RewriteCond和RewriteRules来获取http://www.website.com, http://website.com, https://www.website.com 重定向到https://website.com 目标 此外,任务更复杂,因为我在Apache之后有一个Zope服务器 所以,总结一下,下面是所有这些重写条件和重写规则

在我的一个名为website.com的网站上,我很难用awstats工具CGI脚本、图标和相关的直方图条显示

这个问题相当棘手,因为我使用不同的RewriteCond和RewriteRules来获取http://www.website.com, http://website.com, https://www.website.com 重定向到https://website.com 目标

此外,任务更复杂,因为我在Apache之后有一个Zope服务器

所以,总结一下,下面是所有这些重写条件和重写规则,它们产生了预期的结果,即所有重定向到https://website.com 并通过密码访问awstats工具。一切正常,除了加载后awstats主页中缺少图标和直方图之外:

<VirtualHost *:443>

    # Test local
    ServerAdmin admin@website.com
    ServerName website.com
    ServerAlias www.website.com 

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

    # ACTIVATE SSL
    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/live/website.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/website.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/website.com/chain.pem

    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://website.com/$1 [R=301,L] 
    # your /cgi-bin checks can be merged into one regex 
    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 *

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    Alias /awstatsclasses "/usr/share/awstats/lib/"
    Alias /awstats-icon "/usr/share/awstats/icon/"
    Alias /awstatscss "/usr/share/fdoc/awstats/examples/css"

<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
        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>
我已经把etc放在了所有图标缺失的列表中

2此外,加载awstats主页后,我会在顶部显示以下消息:

结论:我不知道该尝试什么了。但是,从上面的第1部分中,我在Apache2配置文件中明确指出:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
Alias /awstats-icon "/usr/share/awstats/icon"
具有以下权限:

drwxr-xr-x 9 www-data www-data 4096 Apr  2 16:25 /usr/share/awstats/icon/
3最后,我认为最有趣的信息来自Apache2的error.log:

[Thu Apr 02 01:37:04.344047 2020] [proxy:debug] [pid 19209] proxy_util.c(2578): [client 100.87.10.76:40246] AH00947: connected /++vh++https:website.com:443/++/awstats-icon/other/hh.png to localhost:8443, referer: https://website.com/cgi-bin/awstats.pl?framename=mainright
[Thu Apr 02 01:37:04.600404 2020] [proxy:debug] [pid 19209] proxy_util.c(2316): AH00942: HTTPS: has acquired connection for (*)
这显示了Zope中Virtualhost的路径与Apache2中CGI脚本的路径之间的冲突,特别是第一行:

你觉得这些线索怎么样

更新2:根据@Tom Hundt的建议,我对日志重写进行了更深入的分析。下面是我加载awstats主页时得到的信息

[Sun Apr 05 16:17:01.057073 2020] [rewrite:trace3] [pid 25288] mod_rewrite.c(483): [client 31.11.12.101:51422] 31.11.12.101 - - [website.com/sid#7fa0b5d01d98][rid#7fa0ba0930a0/initial] applying pattern '^/(.*)' to uri '/awstats-icon/other/hx.png', referer: https://website.com/cgi-bin/awstats.pl?framename=mainright
[Sun Apr 05 16:17:01.057093 2020] [rewrite:trace3] [pid 25288] mod_rewrite.c(483): [client 31.11.12.101:51422] 31.11.12.101 - - [website.com/sid#7fa0b5d01d98][rid#7fa0ba0930a0/initial] applying pattern '^/(.*)' to uri '/awstats-icon/other/hx.png', referer: https://website.com/cgi-bin/awstats.pl?framename=mainright
[Sun Apr 05 16:17:01.057107 2020] [rewrite:trace2] [pid 25288] mod_rewrite.c(483): [client 31.11.12.101:51422] 31.11.12.101 - - [website.com/sid#7fa0b5d01d98][rid#7fa0ba0930a0/initial] rewrite '/awstats-icon/other/hx.png' -> 'https://localhost:8443/++vh++https:website.com:443/++/awstats-icon/other/hx.png', referer: https://website.com/cgi-bin/awstats.pl?framename=mainright
[Sun Apr 05 16:17:01.057120 2020] [rewrite:trace2] [pid 25288] mod_rewrite.c(483): [client 31.11.12.101:51422] 31.11.12.101 - - [website.com/sid#7fa0b5d01d98][rid#7fa0ba0930a0/initial] forcing proxy-throughput with https://localhost:8443/++vh++https:website.com:443/++/awstats-icon/other/hx.png, referer: https://website.com/cgi-bin/awstats.pl?framename=mainright
[Sun Apr 05 16:17:01.057131 2020] [rewrite:trace1] [pid 25288] mod_rewrite.c(483): [client 31.11.12.101:51422] 31.11.12.101 - - [website.com/sid#7fa0b5d01d98][rid#7fa0ba0930a0/initial] go-ahead with proxy request proxy:https://localhost:8443/++vh++https:website.com:443/++/awstats-icon/other/hx.png [OK], referer: https://website.com/cgi-bin/awstats.pl?framename=mainright
一句有趣的话似乎是:

[Sun Apr 05 16:17:01.057073 2020] [rewrite:trace3] [pid 25288] mod_rewrite.c(483): [client 31.11.12.101:51422] 31.11.12.101 - - [website.com/sid#7fa0b5d01d98][rid#7fa0ba0930a0/initial] applying pattern '^/(.*)' to uri '/awstats-icon/other/hx.png', referer: https://website.com/cgi-bin/awstats.pl?framename=mainright
指示模式“^/*”应用于uri“/awstats icon/other/hx.png”

因此,我得出结论,从一开始我的问题就来自于我在cgi bin目录下的URL上应用的重写规则,即当我这样做时:

RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^/(.*) https://website.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^/cgi-bin/(search|awstats) [NC]
RewriteRule ^/(.*)  RewriteRule ^/(.*)  https://localhost:8443/++vh++https:%{SERVER_NAME}:443/++/$1 [P,L]
您同意吗?

我认为您忘记了引号,如果这不能解决您的问题,请检查apache错误日志


建议:暂时打开mod_重写的日志记录

在http.conf put中:

然后可以选择在shell中执行以下操作

tail -f error_log|fgrep '[rewrite:'

以帮助了解发生了什么。

您当前的配置阻止/cgi-bin/的代理,此处使用RewriteCond:

RewriteCond %{REQUEST_URI} !^/cgi-bin/(search|awstats) [NC]
RewriteRule ^/(.*)  https://localhost:8443/++vh++https:%{SERVER_NAME}:443/++/$1 [P,L]

您还需要对/awstats*短路,这样它们就不会成为zope胡说八道的代理。 默认情况下,多个条件为AND,因此很容易:

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]

请不要在文章末尾添加问候语。读者通常更喜欢这里的技术写作。请宽恕这里的志愿者编辑——我们的人不多,而且有太多的材料需要改进。谢谢。我有时会给你这样的建议:注意,我们更喜欢技术性的写作风格。我们轻轻地劝阻问候,希望你能帮助,谢谢,提前感谢,感谢信,问候,亲切的问候,签名,请你能帮助,闲聊的材料和缩写的txtspk,恳求,你被困多久了,投票建议,元评论等。只需解释你的问题,并展示你已经尝试了什么,你期望什么,实际上发生了什么,它什么也没做。您可以看到我的更新1,其中我提供了有关我的问题的更多信息。您是否可以在没有重写规则和https的情况下测试您的代码,复制文件并在本地主机上使用它,只要测试您的别名(如果它们有效)您的建议意味着太多修改,因为我使用的是VPS,因此无法放置,这是什么?RewriteRule^/*{SERVER_NAME}:443/++/$1[P,L]??,祝你好运localhost以这种方式指的是远程VPS localhost,而不是我发布此问题的计算机的localhost。谢谢你的建议。我已经更新了,你能看看这个吗?
LogLevel alert rewrite:trace3
tail -f error_log|fgrep '[rewrite:'
RewriteCond %{REQUEST_URI} !^/cgi-bin/(search|awstats) [NC]
RewriteRule ^/(.*)  https://localhost:8443/++vh++https:%{SERVER_NAME}:443/++/$1 [P,L]

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]