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

How configure apache httpd to answer HTTP 200 with empty body on specific URL?

· 52CE 我爱测

For our environment we should check availability Apache httpd server. We don't want to create and empty pages for it in documentRoot and we not able to use mod_status (security reason). Is any option to configure apache to answer…

问题原文

原帖链接 · Sergei N Lukin · CC BY-SA 4.0

For our environment we should check availability Apache httpd server. We don't want to create and empty pages for it in documentRoot and we not able to use mod_status (security reason).

Is any option to configure apache to answer always HTTP 200 on specific URL? like:

<location /heart_beat.html>
   Return 200
</location>

Apache 2.2 (mod_ssl, mod_proxy, virtual hosts)

已采纳解答

原帖链接 · HBruijn · CC BY-SA 3.0

The obvious solution would be to create an alias in your configuration and place your empty status page outside of your documentroot so it won't conflict with the URL's your CMS or webmaster might create.

 # Unlikely URL used by loadbalancer for polling
 Alias /sdfjkleruiwbns/dfasdfhasdfjkggfhjfgasqeuryuwerpvbbv/ /var/www/loadbalancer/

With regards to polling by loadbalancers:

The loadbalancers will regularly poll the back-end servers. The results of the poll wil determine if back-end server is healthy and the load-balancer will send requests to a given server or not.

The most basic monitoring supported is a simple TCP-connect check to determine if a service is listening for connections. Normally that test isn’t 100% reliable as it is not uncommon for a listener to still be active when the actual application is unresponsive.

A much better check for a web service would be to retrieve an actual URL, i.e. http://server.local/some/path/page.htm when that URL can be retrieved the loadbalancer considers the node active.

Instead of a static HTML a dynamic health page is even better, but that might be more customisation then required/supported. If everything is OK fi a green light and HTTP status 200 is returned, otherwise an HTTP status of 503 is sent with an orange or red light. A health page would then typically check if all the required conditions for running the application are met, e.g. it can write in the temp space, connect to a back-end database, the license is valid, the maximum queue length hasn’t been reached yet etc. etc. As long as polling that health page won’t result in an effective denial of service of course…

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

资料来源与适用范围

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

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

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