Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Getting 404 error for apache `/server-status` |
|
Author |
|
LearningTechAndDev
Joined: 20 Jan 2024 Posts: 2
|
Posted: Sat 20 Jan '24 16:03 Post subject: Getting 404 error for apache `/server-status` |
|
|
I was told that there's a way to enable a url called `http://<your host>/server-status` and that this page would show you some operational metrics of the apache service. But every time I visit that url, I get 404 page not found. Here's how I set things up:
1. Start a new virtual machine in my office network. The local ip address of this machine is `192.168.0.42`. The machine uses Ubuntu 22.04.
2. I run `apt-get update && apt dist-upgrade -y && apt-get install -y apache2`. This causes Apache 2.4.52 to be installed.
3. The Windows computer I work from has the local ip address of `192.168.0.16`. From this computer, I type `http://192.168.0.42` and I can see the Apache default web page.
4. ON the machine of `192.168.0.42`, I type `a2enmod rewrite && a2enmod status`.
5. I provide the following files
`// /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
```
Then I do a `systemctl restart apache2`.
When my `192.168.0.16` computer loads up `http://192.168.0.42/server-status` via google chrome browser, I get 404.
When I run the command `wget http://192.168.0.42/server-status` from the shell of `192.168.0.42`, I get 404.
When I run the command `wget http://127.0.0.1/server-status` from the shell of `192.168.0.42`, I get 404.
When I run the command `wget http://localhost/server-status` from the shell of `192.168.0.42`, I get 404.
What am I doing wrong? |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 348 Location: UK
|
Posted: Sun 21 Jan '24 20:26 Post subject: |
|
|
The fact you're getting a 404 (rather than a 403), suggests your server-status configuration isn't enabled. You've listed your configuration file, but is the mod_status module being loaded? i.e.
Code: | user@host:~$ more /etc/apache2/mods-available/status.load
LoadModule status_module /usr/lib/apache2/modules/mod_status.so
user@host:~$ ls -l /etc/apache2/mods-enabled/status.load
lrwxrwxrwx 1 root root 29 Sep 27 2021 /etc/apache2/mods-enabled/status.load -> ../mods-available/status.load
|
Beyond that, the "Require local" directive constrains requests to a local host IP or the loopback interface. With your listed configuration, this works for me.
Code: | user@host:~$ wget http://127.0.0.1/server-status
--2024-01-21 18:18:26-- http://127.0.0.1/server-status
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5481 (5.4K) [text/html]
Saving to: ‘server-status’
server-status 100%[=================================>] 5.35K --.-KB/s in 0s
2024-01-21 18:18:26 (1011 MB/s) - ‘server-status’ saved [5481/5481]
|
Once you've got it working, if you want to allow access from remote hosts, you'll need to remove the "Require local" directive. |
|
Back to top |
|
LearningTechAndDev
Joined: 20 Jan 2024 Posts: 2
|
Posted: Tue 23 Jan '24 4:14 Post subject: |
|
|
Ok, for whatever reason, i can actually see the `http://192.168.0.43/server-status` page now from the localhost and from `192.168.0.16`.
All I did was turn off the machine on Saturday. And today, when I turned it on, things are magically working.
on Saturday, I did do things like `systemctl restart apache2`, reboot the machine, etc... But now, on Monday, it decided to work... |
|
Back to top |
|
|
|
|
|
|