无法在 Apache 2.4 上配置服务器状态

无法在 Apache 2.4 上配置服务器状态

我正在尝试在 Apache 2.4 上配置统计信息,但无法使其正常工作。这是我当前的配置:

$ cat sites-enabled/000-default.conf

<VirtualHost *:80>
        Redirect 404 /
        ErrorDocument 404 "Page Not Found"
</VirtualHost>

<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias test.example.com dev.example.com 127.0.0.1 web.example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/modx
    Header set Content-Security-Policy: "frame-ancestors 'self' http://resources.example.com https://resources.example.com http://web.example.com https://web.example.com"
    Header set X-Frame-Options "allow-from https://resources.example.com https://web.example.com"
    Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    SetEnvIf Origin "http(s)?://(www\.)?(devaccess.example.com|testaccess.example.com)$" AccessControlAllowOrigin=$0
    Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin

    <Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Location>
</VirtualHost>

有人能帮帮我吗?我做错了什么?

当我卷曲它时,我得到了这个:

$ curl -v http://127.0.0.1/server-status?auto
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET /server-status?auto HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 127.0.0.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Mon, 13 May 2019 21:08:14 GMT
* Server Apache is not blacklisted
< Server: Apache
< Strict-Transport-Security: max-age=63072000; includeSubDomains
< Location: https://127.0.0.1/server-status?auto
< Content-Length: 244
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://127.0.0.1/server-status?auto">here</a>.</p>
</body></html>
* Connection #0 to host 127.0.0.1 left intact

答案1

我正在尝试在 Apache 2.4 上进行配置mod_status,但无法使其工作。

  1. 确保LoadModule status_module modules/mod_status.so中的 被取消注释httpd.conf(或者,在你的情况下,很可能是/etc/apache2/apache2.conf)。

  2. 请尝试以下操作:

    <Location "/server-status">
         SetHandler server-status
         Require ip 127.0.0.1
    </Location>
    

相关内容