获取 apache `/server-status` 的 404 错误

获取 apache `/server-status` 的 404 错误

有人告诉我有一种方法可以启用一个名为的 URL http://<your host>/server-status,并且此页面会向您显示 apache 服务的一些运行指标。但每次我访问该 URL 时,都会出现 404 页面未找到。以下是我设置的方式:

  1. 在我的办公网络中启动一个新的虚拟机。这台机器的本地ip地址是192.168.0.42。机器使用Ubuntu 22.04。
  2. 我运行apt-get update && apt dist-upgrade -y && apt-get install -y apache2。这将安装 Apache 2.4.52。
  3. 我使用的 Windows 计算机的本地 IP 地址为192.168.0.16。从这台计算机,我输入内容http://192.168.0.42,然后就可以看到 Apache 默认网页。
  4. 在的机器上192.168.0.42,我输入a2enmod rewrite && a2enmod status
  5. 我提供以下文件

// /etc/apache2/apache2.conf

DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
AccessFileName .htaccess
<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>


Include ports.conf
<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>
<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

/etc/apache2/mods-available/status.conf && /etc/apache2/mods-enabled/status.conf

<IfModule mod_status.c>
        # Allow server status reports generated by mod_status,
        # with the URL of http://servername/server-status
        # Uncomment and change the "192.0.2.0/24" to allow access from other hosts.

        <Location /server-status>
                SetHandler server-status
                Require local
                Require ip 192.168.0.42/24
                Require ip 192.168.0.16/24
        </Location>

        # Keep track of extended status information for each request
        ExtendedStatus On

        # Determine if mod_status displays the first 63 characters of a request or
        # the last 63, assuming the request itself is greater than 63 chars.
        # Default: Off
        #SeeRequestTail On


        <IfModule mod_proxy.c>
                # Show Proxy LoadBalancer status in mod_status
                ProxyStatus On
        </IfModule>


</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

接下来,我在机器systemctl restart apache2的 bash 终端中输入内容192.168.0.42

接下来,当我的192.168.0.16电脑通过谷歌浏览器加载时http://192.168.0.42/server-status,出现 404。

wget http://192.168.0.42/server-status当我从 shell运行命令时192.168.0.42,出现 404。

wget http://127.0.0.1/server-status当我从 shell运行命令时192.168.0.42,出现 404。

wget http://localhost/server-status当我从 shell运行命令时192.168.0.42,出现 404。

我究竟做错了什么?

相关内容