開発環境などで雑にBasic認証をかけたい場面がある。そうした環境で特定のパスは認証したくない場合がある。例えば、Let's Encryptでの証明書発行・更新のドメイン検証のリクエストだ。
Nginxの場合、認証の構成によるけれど、Basic認証のみを行っているようなら、以下の様な設定を行うことでそうした要求を満たせる。
satisfy any; deny all; auth_basic "basic authentication"; auth_basic_user_file "/path/to/.htpasswd"; location /.well-known { allow all; }
$ certbot-auto renew ~~~ Congratulations, all renewals succeeded.
Twitterへのつぶやきで済ましていたのだけれど、検索性が悪いので記事にした。
多分こんな感じがいい。
— 光電/7474 (@koudenpa) February 4, 2019
/.well-known 配下は公開してしまえ。
```
satisfy any;
deny all;
auth_basic "basic authentication";
auth_basic_user_file "/path/to/.htpasswd";
location /.well-known {
allow all;
}
```
$certbot-auto renew
~~~
Congratulations, all renewals succeeded.