# Discourse에서 이중 nginx 오류 발생: \`discourse-common/lib/raw-handlebars\`에서 \`handlebars\` 모듈을 찾을 수 없음

**URL:** https://meta.discourse.org/t/discourse-use-double-nginx-error-could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/276847
**Category:** Self-hosting
**Tags:** unsupported-install, two-container
**Created:** [8월 28, 2023, 2:15오전 UTC](https://meta.discourse.org/t/discourse-use-double-nginx-error-could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/276847 "2023-08-28T02:15:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![LeBlanc](https://avatars.discourse-cdn.com/v4/letter/l/e9bcb4/32.png) [@LeBlanc](https://meta.discourse.org/u/LeBlanc)
#### Post date: [8월 28, 2023, 2:15오전 UTC](https://meta.discourse.org/t/discourse-use-double-nginx-error-could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/276847/1 "2023-08-28T02:15:07Z")

</div>

안녕하세요!  
제 웹사이트는 discourse 2.9 버전을 사용하고 있습니다. 어떤 이유에서인지 discourse를 위해 nginx를 이중으로 사용해야 했습니다. 두 개의 discourse web\_only 컨테이너 노드를 배포하고 그 앞에 nginx를 프록시로 사용했습니다. 제 시스템 아키텍처 다이어그램은 다음과 같습니다:

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/3/0/13021d9e2868d593aa24df312c8d398e905cde35.png)

사용자 정의 nginx 프록시로 두 개의 web\_only 컨테이너 노드에 요청을 무작위로 분배했을 때, discourse 웹사이트가 간헐적으로 다음 오류를 보고했습니다: “Could not find module ‘handlebars’ imported from’ discurse-common /lib/raw-handlebars’.” 이 경우 브라우저에서 사이트를 방문하면 흰 화면만 표시됩니다. 그러나 사용자 정의 nginx를 사용하여 모든 요청을 web\_only 노드 중 하나에만 전달하면 이 오류가 발생하지 않습니다. 이 문제에 대해 검색해 보니, 동일한 오류를 해결하기 위한 이전 커밋들이 몇 가지 있었습니다. 제 버전에는 해당 커밋 코드가 포함되어 있는지 확인했습니다.

> [Could not find module 'handlebars' imported from 'discourse-common/lib/raw-handlebars'](https://meta.discourse.org/t/could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/216999)

> [Broken instance after updating to 2.9.0.beta2 - #11 by david](https://meta.discourse.org/t/broken-instance-after-updating-to-2-9-0-beta2/218121/11)

이유를 아시는 분 계신가요? 정말 감사합니다.

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/b/6/5b6a84256cb25150093ab27de954d8dc8b9a134c.png)

---

<div class="post-metadata">

### Author: ![LeBlanc](https://avatars.discourse-cdn.com/v4/letter/l/e9bcb4/32.png) [@LeBlanc](https://meta.discourse.org/u/LeBlanc)
#### Post date: [8월 28, 2023, 2:24오전 UTC](https://meta.discourse.org/t/discourse-use-double-nginx-error-could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/276847/2 "2023-08-28T02:24:11Z")

</div>

참고로, nginx를 이중으로 사용할 때 실제 사용자 IP 주소를 가져오지 못하는 문제가 있습니다. 이는 제가 커스텀 nginx에서 X-Forwarded-For 헤더 필드를 통해 클라이언트 IP 주소를 가져오도록 설정해 두었지만, discourse의 nginx에서 X-Forwarded-For를 비활성화하지 않았기 때문입니다. 그 결과 커스텀 nginx의 X-Forwarded-For 설정이 discourse의 nginx에 의해 덮어쓰기 됩니다.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [8월 28, 2023, 4:34오후 UTC](https://meta.discourse.org/t/discourse-use-double-nginx-error-could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/276847/3 "2023-08-28T16:34:51Z")

</div>

> [@LeBlanc](#):
>
> 하지만 커스텀 nginx를 사용하여 모든 요청을 web\_only 노드 중 하나만에게 전달하도록 했을 때, 이 오류가 발생하지 않습니다.

어떤 것을 사용하든 관계가 없나요? 그리고 동일한 이미지를 실행하고 있나요? 정말 의아한 일입니다.

같은 호스트에서 두 개의 컨테이너를 그렇게 실행하는 것의 유일한 장점은 제로다운타임 업그레이드를 가능하게 하는 것이라고 생각합니다. 자주 업그레이드를 하지 않으시는 것 같으니, 불필요한 복잡성을 가지고 계신 것 같습니다.

> [@LeBlanc](#):
>
> 실제 사용자 IP 주소를 가져올 수 없습니다.

web\_only.yml 파일에 다음과 같은 내용이 필요합니다:

```plaintext
after_bundle_exec:
  - replace:
    filename: /etc/nginx/conf.d/discourse.conf
    from: "types {"
    to: |
      set_real_ip_from 172.16.0.0/12;
      set_real_ip_from 10.0.0.0/8;
      real_ip_recursive on;
      real_ip_header X-Forwarded-For;
      types {

```

---

<div class="post-metadata">

### Author: ![LeBlanc](https://avatars.discourse-cdn.com/v4/letter/l/e9bcb4/32.png) [@LeBlanc](https://meta.discourse.org/u/LeBlanc)
#### Post date: [8월 29, 2023, 2:05오전 UTC](https://meta.discourse.org/t/discourse-use-double-nginx-error-could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/276847/4 "2023-08-29T02:05:46Z")

</div>

답변 주셔서 감사합니다.

> [@pfaffman](#):
>
> 어떤 것을 사용하든 상관없나요? 그리고 동일한 이미지를 실행 중인가요? 그건 좀 의아하네요.

네, 어떤 것을 사용하든 상관없습니다. 동일한 web\_only 이미지를 실행 중입니다. safe-mode를 사용하여 문제를 계속 조사해 보겠으며, 결론이 나면 여기서 다시 보고드리겠습니다.

> [@pfaffman](#):
>
> 같은 호스트에서 두 개의 컨테이너를 그렇게 실행하는 데 제가 볼 수 있는 유일한 이점은 제로 다운타임 업그레이드를 가능하게 하는 것입니다. 자주 업그레이드를 하지 않으시는 것 같으니, 불필요한 복잡성을 가진 것 같습니다.

시스템 아키텍처 다이어그램에서 오해를 드려 죄송합니다. web\_only 배포를 위해 다른 머신을 사용했습니다. web\_only를 이중으로 사용하는 이유는 web\_only 컨테이너가 연결이 너무 많아 한 번 크래시된 적이 있는데, 당시에는 원인을 찾지 못했기 때문입니다. 그래서 같은 문제가 다시 발생하지 않도록 web\_only를 이중으로 사용해보았습니다.

> [@pfaffman](#):
>
> web\_only.yml 파일에 다음과 같은 내용이 필요합니다:
> 
> ```plaintext
> after_bundle_exec:
> - replace:
> filename: /etc/nginx/conf.d/discourse.conf
> from: "types {"
> to: |
> set_real_ip_from 172.16.0.0/12;
> set_real_ip_from 10.0.0.0/8;
> real_ip_recursive on;
> real_ip_header X-Forwarded-For;
> types {
> 
> ```

감사합니다. 덕분에 실제 사용자 IP를 가져오는 문제를 해결할 수 있었습니다.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [8월 29, 2023, 8:22오전 UTC](https://meta.discourse.org/t/discourse-use-double-nginx-error-could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/276847/6 "2023-08-29T08:22:53Z")

</div>

> [@LeBlanc](#):
>
> web\_only를 배포할 때 다른 머신을 사용했습니다.

그렇군요.

연결 수를 늘릴 수 있는 설정이 있습니다.

업그레이드하는 것이 좋겠습니다. 해당 버전에는 몇 가지 문제가 있을 것이며, 이후 여러 보안 문제가 수정되었을 것이라고 확신합니다.

---

<div class="post-metadata">

### Author: ![LeBlanc](https://avatars.discourse-cdn.com/v4/letter/l/e9bcb4/32.png) [@LeBlanc](https://meta.discourse.org/u/LeBlanc)
#### Post date: [8월 30, 2023, 4:02오전 UTC](https://meta.discourse.org/t/discourse-use-double-nginx-error-could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/276847/7 "2023-08-30T04:02:30Z")

</div>

감사합니다. 현재 안전 모드에서 디버깅을 시도해도 동일한 오류가 발생합니다. Discourse를 업그레이드해서 문제를 해결할 수 있을지 확인해 보겠습니다.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [9월 29, 2023, 4:03오전 UTC](https://meta.discourse.org/t/discourse-use-double-nginx-error-could-not-find-module-handlebars-imported-from-discourse-common-lib-raw-handlebars/276847/8 "2023-09-29T04:03:07Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
