# Discourse 인증서 갱신 실패

**URL:** https://meta.discourse.org/t/discourse-failure-to-renew-certificate/385148
**Category:** Bug
**Tags:** letsencrypt
**Created:** [10월 9, 2025, 3:38오후 UTC](https://meta.discourse.org/t/discourse-failure-to-renew-certificate/385148 "2025-10-09T15:38:48Z")
**Posts on this page:** 1
**Showing post:** 15

<div class="post-metadata">

### Author: ![cedric\_chin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cedric_chin/32/536774_2.png) [@cedric\_chin](https://meta.discourse.org/u/cedric_chin)
#### Post date: [12월 22, 2025, 4:32오전 UTC](https://meta.discourse.org/t/discourse-failure-to-renew-certificate/385148/15 "2025-12-22T04:32:51Z")

</div>

> [@lessLost](#):
>
> 바닐라 nginx 설치 환경(1.18.0, 1.26.3에서도 동일할 것으로 보임)에서 테스트해 본 결과, location 블록 외부에 있는 `return 301 https://thehostname$request_uri;`라는 nginx 설정 줄은 캐치올(catch-all) 역할을 하는 것이 아니라, 그 앞의 모든 `location` 블록을 완전히 무시하고 덮어씁니다. 301 리다이렉트가 서버 블록의 끝부분에 있는 `/`와 같은 다른 location을 위한 것이 아니라면, 포트 80에서 `/.well-known/`가 단순히 제공되지 않는다고 생각합니다. [이 stackoverflow 게시물](https://stackoverflow.com/questions/36504449/nginx-redirect-all-but-one)과 동일한 문제일 수 있습니다.

letsencrypt 갱신이 실패한다는 것을 확인했습니다. 저는 수년 동안 셀프호스팅된 Discourse를 운영해 왔는데, 매우 이상하게도 지난 몇 달 동안 두 번 연속으로 갱신이 실패했습니다. 두 번째 실패는 오늘 아침에 있었고, 그래서 조사를 시작했습니다.

다음 두 커밋으로 원인을 추적했습니다:

> <https://github.com/discourse/discourse_docker/pull/959>
>
> This reapplies commit 3c2234830a71e7590a0eaa9b73da46fd2c09ea71 with a fix to kee…p outlet files instead of removing them so \`replace\` continues to work.

그리고 관련 줄 링크:

[https://github.com/discourse/discourse\_docker/commit/c9064be6b7a743e3d86dbc69ddaa80701766aa87#diff-b8c95dfe3760424eecc60d21538dbd785f096d46ef95764c60f4b608f40dd536R26](https://github.com/discourse/discourse_docker/commit/c9064be6b7a743e3d86dbc69ddaa80701766aa87#diff-b8c95dfe3760424eecc60d21538dbd785f096d46ef95764c60f4b608f40dd536R26)

저는 두 가지 문제가 있다고 생각합니다.

첫째, `return 301 https://${DISCOURSE_HOSTNAME}$request_uri;`가 끝에 `$request_uri` 없이 `return 301 https://<내 서버 이름>`으로 변환됩니다. 제 셀프호스팅 설치 환경과 지난주에 설정한 친구의 셀프호스팅 설치 환경에서 모두 확인했습니다. Discourse 템플릿이 어떻게 작동하는지 이해하지 못하므로, 왜 이것이 제거되는지 알 수 없습니다.

둘째, @lessLost가 언급했듯이, 301 리다이렉트는 location 블록 밖에 있습니다. 서버 레벨의 리다이렉트가 모든 location 블록을 무시한다고 생각합니다. LetsEncrypt는 갱신에 http를 사용합니다. 그러나 `curl -I http://YOUR_DOMAIN/.well-known/acme-challenge/test`를 실행하면 404(예상되는 동작; 301이 아닌 404가 필요합니다) 대신 https로 301이 반환됩니다.

제 셀프호스팅 설치 환경에서는 수동으로 이 문제를 수정했지만, 업데이트 시 제 변경 사항이 덮어써질 것으로 예상됩니다. 불행히도 템플릿을 충분히 이해하지 못해 @pfaffman에게 풀 리퀘스트를 제출할 수 없습니다 — 할 수만 있다면 그렇게 할 것입니다.

수정하여 추가:

이것은 오해인 것 같습니다 —

> [@Let's Encrypt 인증서가 자동으로 갱신되지 않는데, 재빌드 시 갱신이 트리거됩니다](https://meta.discourse.org/t/lets-encrypt-certificate-doesnt-automatically-renew-but-rebuilding-does-trigger-the-renewal/383320/5?u=cedric_chin):
>
> I recently worked on the le cert renewal. It is the http to https redirect - acme does not handle being told to redirect well at all and by default attempts to connect on the same protocol (http) as it did when it was setup initially Recent updates to the let’s encrypt template should fix these renewals going forward.

LetsEncrypt가 기본적으로 http를 사용한다는 것에 대해 상당히 확신합니다(명확한 이유: 인증서가 만료되면 갱신할 수 없으므로!). 하지만 서버 블록 레벨에 301을 배치하면 _모든_ 요청이 https로 301되도록 강제되며, 이는 이 갱신 전략과 일치하지 않습니다.

수정 2: [http 갱신 전략](https://community.letsencrypt.org/t/https-prevents-certificate-auto-renewal-why-and-what-to-do/67564/3)에 대한 증거, 하지만 이것을 확인하기 위해 구글에서 검색해 보실 수도 있습니다.

---

_[View the full topic](https://meta.discourse.org/t/discourse-failure-to-renew-certificate/385148)._
