Set up Let’s Encrypt with multiple domains / redirects

오, 드디어 성공했습니다:

true | openssl s_client -connect www.starzen.space:443 2>/dev/null \
| openssl x509 -noout -text \
| perl -l -0777 -ne '@names=/\bDNS:([^\s,]+)/g; print join("\n", sort @names);'
starzen.space
www.starzen.space

재발급을 강제하기 위해 letsencrypt 스크립트의 if 문들을 주석 처리했습니다. 물론 이것은 ‘공식적인’ 해결책은 아닙니다.

하지만 이는 제공된 옵션의 문제가 아니라 ‘상태(state)’ 관련 문제였음을 시사합니다.

현재 스크립트는 이전 상태에 따라 문제가 발생할 수 있지만, 재발급을 강제하면 해결할 수 있습니다.

이제 작동하는 아펙스 도메인(apex domain)을 갖게 되었습니다! :tada:

4개의 좋아요

기본 설치에 포함된 것입니다. User Guide — Certbot 5.8.0 documentation 를 참고한 후 Managing Certificates 섹션으로 스크롤을 내려보세요. 바로 아래에 있는 Re-creating and Updating Existing Certificates 섹션도 확인해 주세요.

이 명령어들은 처음 Certbot을 실행했던 곳에서 실행해야 합니다.

1개의 좋아요

표준 설치 환경이며 certbot은 사용되지 않습니다. “정상적인” 서버 레벨에서도, 그리고 처음 ./launcher enter app를 실행할 때도 마찬가지입니다.

acme.sh 때문에 누락된 것으로 보입니다.

3개의 좋아요

비슷한 문제에 부딪힌 것 같습니다. 서브서브도메인(Let's Encrypt with sub-subdomain?)을 사용했기 때문인 줄 알았는데, 일반 서브도메인으로 시도해 봤지만 새 사이트에 대한 인증서가 여전히 생성되지 않습니다.

어떻게 해킹해서 동작하게 만들었는지 알아내려고 노력하고 있지만, 따라가기가 어렵네요 :grimacing:

여러분은 어떻게 해서 동작하게 만들었나요?

만약 그것이 원인이라면, 어떤 if 문들을 주석 처리했나요?

또한, 이 새로운 문제의 원인이 무엇일지 혹시 아시는 분이 있을까요?

1개의 좋아요

제 문제는 멀티사이트 구성에서 만료된 도메인 이름과 관련이 있었습니다:

2개의 좋아요

@Brahn 님,

최근 지침을 업데이트해 주셔서 감사합니다.

루트 도메인을 서브도메인으로 지정했을 때 인증서 오류가 발생하고 있었습니다. 요청하신 최신 버전으로 app.yml 파일을 업데이트했고, 문제가 해결되었습니다. :slightly_smiling_face:

5개의 좋아요

도메인을 변경한 후 리디렉션이 실패해서 저도 방금 이 문제를 구현해야 했습니다.

위키를 약간 수정하여 기존 지침을 제거하고 새 지침의 공백을 수정했습니다.

하지만 아직까지 효과가 없는 것 같습니다. 새로운 인증서를 발급받도록 강제해야 하는 것 같습니다. 쉽게 할 수 있는 방법을 알려주실 수 있나요?

방금 리빌드를 한 것 같은데, 또 뭔가 바뀐 걸 수도 있겠네요. 이전 인증서가 아직 있나요? 호스트 이름은 무엇인가요? 원하시면 PM으로 연락 주세요.

제이, 감사합니다 - forum.hinz.org.nz는 이전 도메인이고 (ehealthforum.nz가 새로운 도메인입니다).

재빌드를 수행했습니다(2컨테이너 구성으로 web_only만 사용) 하지만, 문제가 해결되지 않았습니다.

1개의 좋아요

호스트 이름도 변경하셨나요? 도메인 이름 변경 또는 Discourse 이름 변경을 수행하셨나요?

비청구 조언: 모범 사례는 에이프ек스 도메인 대신 www를 사용하는 것입니다. 제가 사용하는 브라우저들은 www가 있는 것을 거의 알아채기 어렵게 만듭니다.

제 유일한 추측은 따옴표 안의 끝부분 공백이 중요한데, 그 공백이 없는 것은 아닌지 하는 것입니다.

컨테이너에 들어가서 이리저리 살펴보고, acme가 실행되는 방식대로 실행해 보며 어떤 일이 일어나는지 확인해 볼 것 같습니다. 어떻게 해야 하는지, 또는 acme 명령을 어디서 찾아야 하는지는 기억이 나질 않아서 매번 새로 찾아내야 하므로 알려드릴 수가 없습니다. docker logs web_only를 통해 확인할 수 있을지도 모릅니다.

마지막으로 이 부분을 수정했을 때 잘 작동했다고 맹세합니다. 방금 해당 설정을 적용한 사이트를 확인해 보니, 추가적으로 유효한 인증서가 작동하는 것 같습니다. 하지만 현재 존재하는 것과 다른 베이스 이미지를 가지고 있어서 다음 재빌드 시 깨질 수도 있습니다.

기회가 되면 다시 확인해 보겠습니다. 아마 다음 주에나 가능할 것 같습니다.

2개의 좋아요

네 - 모두 문제없이 처리했습니다.

맞습니다 - 하지만 CDN이나 서브도메인을 사용할 계획이 있을 때만(저는 없습니다) 가치가 있습니다:

추가해 보았지만 차이는 없었습니다.

이것은 꽤 흥미롭습니다 (클릭하여 보기)

root@forumhinz:/var/discourse# docker logs web_only
run-parts: executing /etc/runit/1.d/00-ensure-links
run-parts: executing /etc/runit/1.d/00-fix-var-logs
run-parts: executing /etc/runit/1.d/01-cleanup-web-pids
run-parts: executing /etc/runit/1.d/anacron
run-parts: executing /etc/runit/1.d/cleanup-pids
Cleaning stale PID files
run-parts: executing /etc/runit/1.d/copy-env
run-parts: executing /etc/runit/1.d/letsencrypt
[Sat 9 Sep 08:19:27 UTC 2023] Domains not changed.
[Sat 9 Sep 08:19:27 UTC 2023] Skip, Next renewal time is: 2023-10-26T08:24:32Z
[Sat 9 Sep 08:19:27 UTC 2023] Add ‘–force’ to force to renew.
[Sat 9 Sep 08:19:29 UTC 2023] Installing key to: /shared/ssl/ehealthforum.nz.key
[Sat 9 Sep 08:19:29 UTC 2023] Installing full chain to: /shared/ssl/ehealthforum.nz.cer
[Sat 9 Sep 08:19:29 UTC 2023] Run reload cmd: sv reload nginx
warning: nginx: unable to open supervise/ok: file does not exist
[Sat 9 Sep 08:19:29 UTC 2023] Reload error for :
[Sat 9 Sep 08:19:29 UTC 2023] Domains not changed.
[Sat 9 Sep 08:19:30 UTC 2023] Skip, Next renewal time is: 2023-10-26T08:24:45Z
[Sat 9 Sep 08:19:30 UTC 2023] Add ‘–force’ to force to renew.
[Sat 9 Sep 08:19:31 UTC 2023] Installing key to: /shared/ssl/ehealthforum.nz_ecc.key
[Sat 9 Sep 08:19:31 UTC 2023] Installing full chain to: /shared/ssl/ehealthforum.nz_ecc.cer
[Sat 9 Sep 08:19:31 UTC 2023] Run reload cmd: sv reload nginx
warning: nginx: unable to open supervise/ok: file does not exist
[Sat 9 Sep 08:19:31 UTC 2023] Reload error for :
Started runsvdir, PID is 570
supervisor pid: 578 unicorn pid: 590

이것은 강제로 갱신하는 방법을 찾지 못하면, 문제가 해결될 때까지 [date=2023-10-26 time=08:24:00 timezone=“Universal”]까지 기다려야 한다는 것을 의미합니다!

몇 가지 방법을 시도해 보겠습니다 - 행운을 빕니다.

나중에…

성공!

여러 번 시도하고 실패한 끝에, 결국 새 서버로 이전했습니다(이미 계획되어 있던 일이었습니다).

놀랍게도, OP의 설정으로 인증서가 완벽하게 갱신되었습니다. 정말 이해가 안 됩니다.

앞으로 어떻게 더 잘할 수 있을지 확신이 서지 않습니다. 아마도 새 도메인의 DNS 설정을 1~2개월 일찍 설정하고, 그 줄들을 app.yml에 넣는 것이 좋겠습니다.

2개의 좋아요

app.yml 파일에 이 내용을 추가했는데, 재빌드가 필요한가요? 아니면 바로 적용되나요?
또한, "from: /-d www.first-domain.com/"에서 리다이렉트하려는 도메인을 넣어야 하는지, 아니면 서브도메인을 넣어야 하는지 궁금합니다.

1개의 좋아요

네, app.yml에 변경 사항이 있으면 일반적으로 재빌드가 필요합니다.

3개의 좋아요

다시 빌드했는데 이제 내 사이트를 접속할 수 없습니다. 다시 빌드해야 하나요?
빌드 후 다음과 같은 메시지가 표시됩니다.

"Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile' failed with return #<Process::Status: pid 3575 exit 134>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"assets_precompile", "cmd"=>["su discourse -c 'bundle exec rake themes:update assets:precompile'"]}
bootstrap failed with exit code 134
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one."
1개의 좋아요

재구축 과정이 오류 없이 순조롭게 진행되었나요?

2개의 좋아요

위와 같이 해보시고 오류 메시지를 공유해 주세요.

2개의 좋아요

다음과 같은 경고가 표시되었는데, 이것이 중요한지 잘 모르겠습니다.

warning " > @glint/environment-ember-loose@1.1.0" has unmet peer dependency "@glimmer/component@^1.1.2".
warning " > @glint/environment-ember-template-imports@1.1.0" has unmet peer dependency "ember-template-imports@^3.0.0".
warning Resolution field "unset-value@2.0.1" is incompatible with requested version "unset-value@^1.0.0"
warning Pattern ["wrap-ansi@^7.0.0"] is trying to unpack in the same destination "/home/discourse/.cache/yarn/v6/npm-wrap-ansi-cjs-7.0.0-67e145cff510a6a6984bdf1152911d69d2eb9e43-integrity/node_modules/wrap-ansi-cjs" as pattern ["wrap-ansi-cjs@npm:wrap-ansi@^7.0.0"]. This could result in non-deterministic behavior, skipping.
warning " > discourse-markdown-it@1.0.0" has unmet peer dependency "xss@*".
warning "workspace-aggregator-68bace53-129d-4a2d-85c3-4685b91c92ee > discourse > @ember/legacy-built-in-components@0.5.0" has incorrect peer dependency "ember-source@>= 4.8".
warning "workspace-aggregator-68bace53-129d-4a2d-85c3-4685b91c92ee > discourse > @uppy/aws-s3@3.0.6" has incorrect peer dependency "@uppy/core@^3.1.2".
warning "workspace-aggregator-68bace53-129d-4a2d-85c3-4685b91c92ee > discourse > @uppy/aws-s3-multipart@3.1.3" has incorrect peer dependency "@uppy/core@^3.1.2".
warning "workspace-aggregator-68bace53-129d-4a2d-85c3-4685b91c92ee > discourse > @uppy/xhr-upload@3.1.1" has incorrect peer dependency "@uppy/core@^3.1.2".
warning "workspace-aggregator-68bace53-129d-4a2d-85c3-4685b91c92ee > discourse-plugins > ember-this-fallback@0.4.0" has unmet peer dependency "ember-source@^3.28.11 || ^4.0.0".
warning "workspace-aggregator-68bace53-129d-4a2d-85c3-4685b91c92ee > discourse > @uppy/aws-s3 > @uppy/xhr-upload@3.3.0" has incorrect peer dependency "@uppy/core@^3.2.1".
<--- Last few GCs --->

[3710:0x6291170]   681247 ms: Scavenge 942.0 (1034.0) -> 940.8 (1034.0) MB, 62.9 / 0.0 ms  (average mu = 0.704, current mu = 0.878) allocation failure;
[3710:0x6291170]   681616 ms: Scavenge 942.4 (1034.0) -> 941.4 (1034.0) MB, 18.3 / 0.0 ms  (average mu = 0.704, current mu = 0.878) allocation failure;
[3710:0x6291170]   681911 ms: Scavenge 943.0 (1034.0) -> 942.0 (1038.0) MB, 46.8 / 0.0 ms  (average mu = 0.704, current mu = 0.878) allocation failure;
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb83f50 node::Abort() [ember]
 2: 0xa94834  [ember]
 3: 0xd647c0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ember]
 4: 0xd64b67 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ember]
 5: 0xf42265  [ember]
 6: 0xf5474d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ember]
 7: 0xf2ee4e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [ember]
 8: 0xf30217 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [ember]
 9: 0xf113ea v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [ember]
10: 0x12d674f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [ember]
11: 0x17035b9  [ember]
Aborted (core dumped)
error Command failed with exit code 134.

그리고 제 사이트에는 다음과 같이 표시됩니다.

이 사이트를 열 수 없습니다

forum.mysite.ca의 연결이 거부되었습니다.

다음을 시도해 보세요:

  • 연결 상태 확인
  • [프록시 및 방화벽 확인]

ERR_CONNECTION_REFUSED"

제 app.yml 파일은 다음과 같습니다.

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-zoom.git
  after_ssl:
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /-d www.mysite.ca/
        to: "-d www.mysite.ca -d mysite.ca "
## 빌드 후 실행할 사용자 지정 명령
1개의 좋아요

서버에 메모리가 얼마나 있으며, 스왑이 활성화되어 있나요? (free -h 명령으로 확인할 수 있습니다.)

               total        used        free      shared  buff/cache   available
Mem:             957         190         371           3         395         613
Swap:           2047          79        1968

서버에 1GB의 RAM과 2GB의 스왑이 할당되어 있습니다. 이상하게도, 이 스왑 용량에서는 재구축 프로세스가 실패할 수 있습니다.

다시 재구축을 시도해 볼 수 있습니다. 실패할 경우, 가능하면 서버 메모리를 업그레이드해야 할 수 있습니다(구축 프로세스 동안에만 적용하며, 완료 후 다운그레이드할 수 있습니다).

1개의 좋아요