Apache config for heartbeat and proxy pass through to ELB

amazon ec2amazon-elbapache-2.2

I am running Apache 2.2.15 on Linux in AWS using ELBs.

My goal is to provide two functions:

1) Heartbeat page for my ELB to check to see if Apache is running (/healthcheck.html)

2) For all other requests, send to an ELB in the next tier via ProxyPass

I have placed a simple html file in /var/www/html named healthcheck.html.

Here's my config:

<VirtualHost *:80>
   <Directory "/var/www/html">
    allow from all
   </Directory>
    ProxyRequests Off
    ProxyPass / http://bigassawsdomainname.com:80/  
    ProxyPassReverse / http://bigassawsdomainname.com:80/ 
    ProxyPreserveHost On
</VirtualHost>

The proxy functionality seems to be working fine. However, hitting localhost/healthcheck.html returns a 404.

I am quite sure my config is not set up correctly. How should I configure this? I've experimented with location and directory with no luck.

Update:

Solution:

NameVirtualHost *:80

<VirtualHost *:80>
    ProxyRequests Off
    <LocationMatch "^(?!/healthcheck.html)">
     ProxyPassMatch http://bigassawsdomainname.com:80/  
    </LocationMatch>
    ProxyPassReverse / http://bigassawsdomainname.com:80/ 
    ProxyPreserveHost On
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /var/www/html
    <LocationMatch /healthcheck.html>
    RewriteEngine On
    RewriteRule ^/$ /healthcheck.html [L]
   </LocationMatch>
</VirtualHost>

Best Answer

You can use a negative lookahead in a locationmatch block to proxy everything except healthcheck.html:

https://stackoverflow.com/questions/8545680/how-to-tell-apache-to-locationmatch-opposite-of-this

<LocationMatch "^(?!/healthcheck.html)">
  ProxyPassMatch http://bigassawsdomainname.com:80/  
</LocationMatch>

(the proxypassreverse should be outside the locationmatch)

Related Topic