Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In my apache2 server I access /server-status to check my current status of the web-server. I found that mods-available/status.conf contains the snippets that is responsible for showing status.

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

My question is how can i make it available not only for localhost but also for remote host with authentication?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

To allow other hosts, you can just update line:

Allow from localhost ip6-localhost

to read:

Allow from localhost ip6-localhost 1.2.3.4 1.2.3

For the authentication part, you add a block like:

AuthType Basic
AuthName "Restricted Files"
# (Following line optional)
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require user rbowen 

The passwords file need to be created using htpasswd utility. Have a look at this page for more details.

share|improve this answer
    
You can allow single IP like 1.2.3.4 or subnet like 1.2.3. –  Khaled Apr 9 '12 at 9:12
    
Will it allow hackers to brute force attack on this page to get information? –  Shiplu Apr 9 '12 at 9:15
    
@Shiplu: If an IP is not allowed, it will receive forbidden error. –  Khaled Apr 9 '12 at 9:22
    
I am from a B class network where I have 65k peers. And my IP is dynamic. So I will set the network not a fixed ip. In that case if any of my peer tries to brute force it what should I do? –  Shiplu Apr 9 '12 at 9:26
1  
@Shiplu: No, you are not "from a B class network" -- unless you're making requests from September 1993. –  womble Apr 9 '12 at 10:40

In the <Location /server-status> stanza, include both the Allow from localhost and authentication directives. The key is to use Satisfy Any to specify that requests from localhost can bypass authentication.

Edit: Explicit example, as requested (it just combines everything that everyone has said so far):

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Satisfy Any

    Allow from localhost ip6-localhost

    AuthType basic
    AuthName "Apache status"
    AuthUserFile /etc/apache2/passwd-server-status
    Require valid-user
</Location>
share|improve this answer
    
Could you show an example? –  Shiplu Apr 9 '12 at 9:22
    
Thanks. I was actually looking for a Satisfy Any directive example. –  Shiplu Apr 9 '12 at 10:49

You can use something similar:

<Location /server-status>
    SetHandler server-status
    AuthType basic
    AuthName "Apache status"
    AuthUserFile /etc/apache2/passwd-server-status
    Require valid-user
</Location>

Also, don't forget to create the password file and account for yourself with the following command (replace username with whatever username you prefer):

htpasswd -c /etc/apache2/passwd-server-status username
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.