apache `/server-status` 出現 404 錯誤

apache `/server-status` 出現 404 錯誤

有人告訴我,有一種方法可以啟用一個名為 url 的方法http://<your host>/server-status,而該頁面將向您顯示 apache 服務的一些操作指標。但每次我造訪該網址時,都會收到 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電腦透過 google chrome 瀏覽器載入時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。

我究竟做錯了什麼?

相關內容