ELBのヘルスチェック(200)を受け入れつつBasic認証をかける
ELB (ALB) + EC2*2(apache)にvirtual hostでマッピングしたサービスにBasic認証をかけたい。
ただしELBはstatus=200のチェックのままで、この辺はいじりたくないなぁって時の話です。
上記のようなAWS上の設定やアプリの設定を極力変えずにBasic認証をかけるには、
アプリのディレクトリにある.htaccessで対応するのではなく、virtualhostのconfや別途追加の設定ファイル等を用意し、
そちらでELBヘルスチェックのUAを貫通させるのがよさそう。
Wanna enable to Basic Authentication without any modifications to AWS and App configuration.
This time is for ELB (ALB) + EC2*2(apache), and ELB healthchek remains 200 or as it is.
For about it, you'd better to prepare an apache virtualhost configuration file or something like that, and allow UA of ELB healthcheck to access without Basic Authentication inside that.
For example like this.
例)
/etc/httpd/conf.d/vhost.deny_access.conf
<Directory /path/to/app> Require valid-user AuthType Basic AuthName "Please enter your ID and password" AuthUserFile /path/to/.htpasswd # Satisfy AnyでOR条件にしてELB-HealthCheckerで始まるUAのみ許可する Satisfy Any Order Deny,Allow SetEnvIf User-Agent "^ELB-HealthChecker.*$" noAuth Allow from env=noAuth Deny from all </Directory>