0

I am running node apache-exporter (https://github.com/Lusitaniae/apache_exporter) in the same Docker container (build from httpd image) as Apache itself. (So am able to distribute the service directly with the container by one Dockerfile and one docker-compose other like using two Dockerfiles and combine the 2 containers in one docker-compose file.)

The apache-exporter (and the Apache server) runs and I can see the apache-up data in Prometheus/Grafana.

I have inserted the Location block inside my httpd.conf

<VirtualHost *:80>
  ServerName XXX.XXX.XXX.XX
  ServerAlias www.XXX.XXX.XXX.XX
  <Location /server-status>
    SetHandler server-status
    #Require local
    Require host example.com
    #Require ip YYY.YYY.YYY.YYY 
  </Location>
  Redirect permanent / https://XXX.XXX.XXX.XXX
</VirtualHost>

XXX.XXX.XXX.XXX = external IP, YYY.YYY.YYY.YYY = IP inside docker network and loaded the modules

LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so

But I got the error:

level=error msg="Error scraping apache: error scraping apache: Get \"https:///XXX.XXX.XXX.XXXserver-status/?auto\": dial tcp: lookup XXX.XXX.XXX.XXXserver-status on YYY.YYY.YYY.YYY: no such host" source="apache_exporter.go:571"

What is wrong? Is a / missing somewhere? Do I have to write the Location block inside another VirtualHost block using another ServerName? Do I have to set --scrape_uri? I guess it is just a stupid mistake by me because the / is missing between IP and server-status. I seems that the Location is not considered and thus the URL is processed by Redirect permanent. Using several ProxyPass inside a VirtualHost is possible when placing the / redirection last.

I want to restrict access to server-status to the Apache-container itself.

3
  • Simply removing Redirect permanent might help. That is, an automatic redirect to server-status may already be in place. Nov 29, 2021 at 10:15
  • Thanks a lot - it works. I also needed a Require all granted inside the location block.
    – LeifSec
    Nov 30, 2021 at 6:50
  • You're welcome. Good to know things got figured out. =) Nov 30, 2021 at 15:14

1 Answer 1

1

It works using this configuration:

<VirtualHost *:80>
  ServerName XXX.XXX.XXX.XX
  ServerAlias www.XXX.XXX.XXX.XX
  <Location /server-status>
    SetHandler server-status
    Require all granted
    Require host example.com
  </Location>  
</VirtualHost>
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 30, 2021 at 9:12

You must log in to answer this question.

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