1

I enabled the following on httpd.conf:

ExtendedStatus On

LoadModule status_module modules/mod_status.so

and also:


NameVirtualHost *:80

<VirtualHost *:80>
  ServerName myserver.com
  ServerAlias myserver.com 

  DocumentRoot /prod/html

  RewriteEngine on
  RewriteCond %{HTTP_HOST} .*myserver.com$
  RewriteRule /(.*) http://myserver.com/$1 [R,L]





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

</VirtualHost>

when running lynx http://localhost/server-status get the following message: You don't have permission to access /server-status on this server.

I don't see anything related to /server-status in my /etc/httpd folder these are the folders I have under /etc/httpd:

**conf
conf.d
logs -> ../../var/log/httpd
modules -> ../../usr/lib/httpd/modules
run -> ../../var/run**

any idea why I get the "permission denied" error? do I need to install another package for get it? Thanks!! Dotan.

6
  • Maybe there is something wrong with VirtualHosts' configuration. It's hard to say without looking at full dump of Apache configuration. Did you restart Apache? Is there anything in ErrorLog?
    – 0xFF
    Dec 27, 2012 at 19:32
  • This is the error I get: [Thu Dec 27 20:05:17 2012] [error] [client 127.0.0.1] client denied by server configuration: /prod/html/server-status
    – edotan
    Dec 27, 2012 at 20:06
  • here is my httpd.conf:
    – edotan
    Dec 27, 2012 at 21:42
  • Try adding ServerAlias localhost to this VirtualHost declaration. Try lynx http://myserver.com/server-status. Try temporary disabling mod_rewrite. As @Epaphus suggested try moving server-status declaration outside VirtualHost. Do you have any other VirtualHosts configured?
    – 0xFF
    Dec 28, 2012 at 6:04
  • I added ServerAlias localhost and disabled the mod_rewrite but still I get [error] [client 127.0.0.1] client denied by server configuration: /prod/html/server-status
    – edotan
    Dec 28, 2012 at 18:42

5 Answers 5

2

Try it with the IP instead of the host name, This is how mine looks ( ::1 is there as the server also has IPv6 enabled)

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1 ::1
</Location>

Using

lynx http://localhost/server-status 

might not be matching the virtual host "myserver.com" so you could try putting the Location /server-status outside of the VirtualHost in the http.conf

3

Just in case this helps someone:

In newer versions of Apache there is a default server-status config setting in conf/extra/httpd-info.conf which will override any server-status settings in httpd.conf

That default config in conf/extra/httpd-info.conf is set to “Allow from .example.com” and will annihilate all fancy server-status changes you do in httpd.conf

So if you are facing permission issues make sure you are editing the proper file!

2
  • 1
    How new of Apache version? And how do you know that this isn't something peculiar to your distribution (which you forgot to mention)? Aug 27, 2013 at 20:02
  • 1
    I've been searching all over for an answer but this was it. Thank you so much! It was being overridden by (for me, on Debian) /etc/apache2/mods-enabled/status.conf
    – vqdave
    Jan 9, 2018 at 1:13
0

You might want to look at your /etc/hosts

127.0.0.1 localhost
0

In my case I checked the /etc/hosts and found out that I have 2 hostnames listed for localhost:

127.0.0.1       localhost.localdomain   localhost

It seems some weird behavior between apache and the resolver. If the first 127.0.0.1 entry is localhost.localdomain you should have it in apache config:

Allow from localhost.localdomain

then you can get the proper answer with both

curl localhost/server-status
curl localhost.localdomain/server-status
curl 127.0.0.1/server-status
0

I have ran into a similar issue while trying to enable the status page for an Apache web server running in Kubernetes.

This was the image that I have been working with: registry.k8s.io/hpa-example, equipped with Apache/2.4.10 (Debian) PHP/5.6.14.

Solution

I've simply created a custom config file (/etc/apache2/conf-enabled/my-custom-config.conf) with the following contents

<Location "/server-status">
  SetHandler server-status
  Require all granted
</Location>

and passed it to the Pod as a Volume. Note: This configuration is not not be used in production as Apache will allow any caller to view the status page. This was OK for my testing purposes.


This was the deployment yaml that I ended up using:

apiVersion: v1
kind: ConfigMap
metadata:
  name: apache-config
data:
  my-custom-config.conf: |
    <Location "/server-status">
      SetHandler server-status
      Require all granted
    </Location>

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: php-apache
spec:
  selector:
    matchLabels:
      run: php-apache
  template:
    metadata:
      labels:
        run: php-apache
    spec:
      containers:
      - name: php-apache
        image: registry.k8s.io/hpa-example
        volumeMounts:
        - name: apache-config
          mountPath: /etc/apache2/conf-enabled/
        ports:
        - containerPort: 80
      volumes:
      - name: apache-config
        configMap:
          name: apache-config

---
apiVersion: v1
kind: Service
metadata:
  name: php-apache
  labels:
    run: php-apache
spec:
  ports:
  - port: 80
  selector:
    run: php-apache

This is how I've ran the server:

kubectl apply -f <path_to_the_deployment_yaml>

This is how I've tested the status page:

kubectl run -i --tty test-pod --rm --image=busybox:1.28 \
  --restart=Never -- /bin/sh -c "wget -O- http://php-apache/server-status"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .