大网数据广告活动
服务器运维问答

Unable to limit Apache server-status page to localhost

· 52CE 我爱测

I am using Apache 2.4.18 on Ubuntu. I want to allow reading server status only from localhost. In /etc/apache2/mods-enabled/status.conf I have: <Location /server-status> SetHandler server-status Require ip 127.0.0.1 </Location> I…

问题原文

原帖链接 · Madoc Comadrin · CC BY-SA 3.0

I am using Apache 2.4.18 on Ubuntu.

I want to allow reading server status only from localhost.

In /etc/apache2/mods-enabled/status.conf I have:

<Location /server-status>
          SetHandler server-status
          Require ip 127.0.0.1
</Location>

I have read https://httpd.apache.org/docs/2.4/howto/access.html and and from I belive the above configuration should be working. I have restarted Apache to ensure that new configuration is active. However the status page is still open for reading from anywhere.

In /etc/apache2/sites-enabled/mysite.conf I have:

 DocumentRoot /var/www
 <Location />
        Require all granted
 </Location>

What is wrong with my configuration?

已采纳解答

原帖链接 · krisFR · CC BY-SA 4.0

From what i can see, the virtual host config file seems to take precedence over the mod_status config file.

Actually you grant all to / within mysite.conf :

<Location />
        Require all granted
</Location>

This results in that everyone can access /server-status.

You would have to manage permissions to /server-status in the virtual host config file itself /etc/apache2/sites-enabled/status.conf :

DocumentRoot /var/www
 <Location />
        Require all granted
 </Location>
 <Location /server-status>
        Require local
 </Location>

From there, whatever permissions you set in /etc/apache2/mods-enabled/status.conf they will be ignored as /etc/apache2/sites-enabled/status.conf takes precedence.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-09-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。