• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Apache for Newbie: Set up Apache with mod_proxy_hcheck

December 17, 2023

Apache for Newbie: Set up Apache with mod_proxy_hcheck

Apache is one of the most popular web servers in the world, known for its flexibility, reliability, and performance. It is widely used to serve websites and applications across various industries. In this article, we will explore how to set up Apache with mod_proxy_hcheck, a module that provides health checking capabilities for proxy balancer members.

What is mod_proxy_hcheck?

Mod_proxy_hcheck is an Apache module that allows you to perform health checks on the backend servers in a proxy balancer configuration. It periodically checks the availability and responsiveness of the backend servers and adjusts the load balancing accordingly. This ensures that only healthy servers receive traffic, improving the overall performance and reliability of your web application.

Setting up Apache with mod_proxy_hcheck

Before setting up Apache with mod_proxy_hcheck, make sure you have Apache installed and configured on your server. Once you have Apache up and running, follow these steps to set up mod_proxy_hcheck:

Step 1: Enable mod_proxy and mod_proxy_balancer

Mod_proxy_hcheck depends on mod_proxy and mod_proxy_balancer, so you need to enable these modules first. Open your Apache configuration file (usually located at /etc/httpd/conf/httpd.conf or /etc/apache2/apache2.conf) and uncomment the following lines:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

Save the changes and restart Apache for the changes to take effect.

Step 2: Install mod_proxy_hcheck

Mod_proxy_hcheck is not included in the default Apache installation. You need to download and install it separately. Visit the Apache website or search for mod_proxy_hcheck on your distribution’s package manager to find the appropriate package for your system. Install the package using the package manager or by following the instructions provided.

Step 3: Configure mod_proxy_hcheck

Once mod_proxy_hcheck is installed, you need to configure it in your Apache configuration file. Open the file and add the following lines:

ProxyHCTemplate hcheck
ProxyHCExpr ok200 {%{REQUEST_STATUS} =~ /^[23]/}
ProxyHCExpr 5xx {%{REQUEST_STATUS} =~ /^[5]/}
ProxyHCExpr !ok200 !5xx
ProxyHCBurst 10
ProxyHCFallback off

The above configuration sets up a health check template named “hcheck” and defines the conditions for a successful health check. In this example, a response with a status code starting with 2 or 3 is considered successful, while a response with a status code starting with 5 is considered a failure. The ProxyHCBurst directive specifies the number of requests to send in each health check burst, and ProxyHCFallback disables the fallback mechanism.

Step 4: Configure the proxy balancer

Next, you need to configure the proxy balancer to use mod_proxy_hcheck for health checking. Add the following lines to your Apache configuration file:


<Proxy "balancer://mycluster">
    BalancerMember http://backend1.example.com route=backend1 hcmethod=hcheck hcuri=/healthcheck
    BalancerMember http://backend2.example.com route=backend2 hcmethod=hcheck hcuri=/healthcheck
    ProxySet lbmethod=byrequests
</Proxy>

ProxyPass "/myapp" "balancer://mycluster/myapp" stickysession=JSESSIONID
ProxyPassReverse "/myapp" "balancer://mycluster/myapp"

In the above configuration, we define a proxy balancer named “mycluster” with two backend servers: backend1.example.com and backend2.example.com. The hcmethod=hcheck parameter tells Apache to use mod_proxy_hcheck for health checking, and the hcuri=/healthcheck parameter specifies the URI to use for health checks. The ProxySet directive sets the load balancing method to “byrequests”. The ProxyPass and ProxyPassReverse directives define the URL mapping for the proxy balancer.

Step 5: Restart Apache

Save the changes to your Apache configuration file and restart Apache for the changes to take effect. You can use the following command to restart Apache:

sudo service apache2 restart

Conclusion

Setting up Apache with mod_proxy_hcheck allows you to perform health checks on your backend servers and ensure that only healthy servers receive traffic. This improves the performance and reliability of your web application. By following the steps outlined in this article, you can easily set up Apache with mod_proxy_hcheck and take advantage of its powerful health checking capabilities.

Summary

In summary, Apache with mod_proxy_hcheck is a powerful combination that allows you to perform health checks on your backend servers in a proxy balancer configuration. By periodically checking the availability and responsiveness of the backend servers, you can ensure that only healthy servers receive traffic, improving the overall performance and reliability of your web application. To learn more about VPS hosting and how it can benefit your business, visit Server.HK.

Recent Posts

  • How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  • CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  • Top 5 Use Cases for a Hong Kong Dedicated Server in 2026
  • Hong Kong VPS vs Japan VPS: Head-to-Head for Asia-Pacific Deployments in 2026
  • Hong Kong VPS vs Singapore VPS: Which Is Better for Your Asia Business in 2026?

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot