Brew the Mash

クラフトビール好きなITエンジニア@mashmorgan_jpの開発メモなど

【nginx】Let's Encryptを導入しようとすると404エラーになってしまう

個人メモ。

nginx環境でLet's Encryptを導入し、諸々設定が完了した後に証明書取得または更新しようとするとなぜか404エラーが発生。(Domainは適当です)

1 renew failure(s), 0 parse failure(s)

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: sub.hogehoge.com
   Type:   unauthorized
   Detail: Invalid response from
   http://sub.hogehoge.com/.well-known/acme-challenge/JgEbIbmmtxbUoM0eNRk9cLmU6vU4JRjj6PhLAhO065w:
   "<html>\r\n<head><title>404 Not Found</title></head>\r\n<body
   bgcolor=\"white\">\r\n<center><h1>404 Not
   Found</h1></center>\r\n<hr><center>"

あれ、confファイルの設定ミスかと思い確認したが特に問題なさそう。

うーんと悩んでたがあっさり--nginxオプションをつけるだけでSuccessしました。

詳しい方は知ってると思いますが今までApacheしか使ってなかったのでなかなか慣れませんね。。。

# 自分はrenewしたかったのでこんな感じで確認しました
./certbot-auto renew --dry-run  //error
# ↓
./certbot-auto renew --nginx --dry-run  //ok