Custom Apache Status page
Posted 4 years ago in Tutorial
I spent a good amount of time tweaking the performance of my VPS after learning about several sites hotlinking images from one of my own websites.
Now, this particular tutorial/article won’t be really about Apache performance, rather I’d like to share a little trick I learned for making your Apache server status page more usable.
First, we need to enable our
/server-status page. To do this, we’ll need to enable the
status Apache module.
Great, now let’s set up a page that will show our server’s actual status page.
According to apache.org, the settings should look something like this:
<Location /server-status> SetHandler server-status Order Deny,Allow Deny from all Allow from .example.com </Location>
Save, reload apache –
service apache2 reload
And you’re good to go! Navigate to yourwebsite.com/server-status and you should see something like this.
Out of the box, the server status page doesn’t look like much. And don’t even try to view it on your phone. Luckily, there’s something we can do to improve this.
I came across this article that explains how to use Apache’s substitute module to inject custom CSS – or any other content – to your page.
I also made it so that only certain IP addresses are allowed to view my server status page (feel free to take it a step further and set up a password as well).
status.conf file looks like this.
<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from IPADDRESS1 IPADDRESS2 IPADRESS3 AddOutputFilterByType SUBSTITUTE text/html SetOutputFilter SUBSTITUTE;DEFLATE Substitute 's|</head>|<style type="text/css">@import "/other/server-status/status.css"</style><meta name="viewport" content="width=device-width, initial-scale=1"></head>|' </Location>
Here is my custom CSS.
And the result:
Being able to inject custom HTML into your server status page gives you quite a lot of freedom, as this person’s Pimped Apache Server Status project shows: