我正在使用ELB在AWS上运行Apache 2.2.15。
我的目标是提供两个function:
1)我的ELB心跳页面检查以查看Apache是否正在运行(/healthcheck.html)
2)对于所有其他请求,通过ProxyPass发送到下一层的ELB
我已将一个简单的html文件放在名为healthcheck.html的/ var / www / html中。
这是我的configuration:
<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>
代理function似乎工作正常。 但是,打本地主机/ healthcheck.html返回一个404。
我很确定我的configuration没有正确设置。 我应该如何configuration? 我已经尝试了位置和目录没有运气。
更新:
解:
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>
您可以在位置匹配代码块中使用负面预测来代理除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>
(proxypassreverse应该在locationmatch之外)