중국 대륙의 GFW 환경에서 Discourse 자체 호스팅

배경

Discourse의 자체 호스팅 문서는 훌륭하며, 설치 과정도 순조롭게 진행되었습니다. 그러나 대만 중국(중국 본토)에서 만리방화벽 뒤에 서버를 배포할 때 문제를 겪었습니다.

문제

./launcher rebuild app을 실행할 때마다 네트워크 제한으로 인해 프로세스가 실패합니다. 아래는 주요 오류 메시지입니다:

I, [2025-01-14T10:21:45.402169 #1]  INFO -- : Scope: all 17 workspace projects
Lockfile is up to date, resolution step is skipped
Progress: resolved 1, reused 0, downloaded 0, added 0
Packages: +87 -15
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Progress: resolved 87, reused 46, downloaded 0, added 33
Progress: resolved 87, reused 46, downloaded 18, added 53
Progress: resolved 87, reused 46, downloaded 25, added 61
Progress: resolved 87, reused 46, downloaded 29, added 66
Progress: resolved 87, reused 46, downloaded 30, added 67
Progress: resolved 87, reused 46, downloaded 30, added 68
 WARN  GET https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.9.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-1.10.4.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@embroider/compat/-/compat-3.8.0.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.7.2.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/ace-builds/-/ace-builds-1.37.4.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.9.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-1.10.4.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@embroider/compat/-/compat-3.8.0.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.7.2.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
 WARN  GET https://registry.npmjs.org/ace-builds/-/ace-builds-1.37.4.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
 ERR_SOCKET_TIMEOUT  request to https://registry.npmjs.org/@embroider/compat/-/compat-3.8.0.tgz failed, reason: Socket timeout

FetchError: request to https://registry.npmjs.org/@embroider/compat/-/compat-3.8.0.tgz failed, reason: Socket timeout
    at ClientRequest.<anonymous> (/usr/lib/node_modules/pnpm/dist/pnpm.cjs:66979:18)
    at ClientRequest.emit (node:events:517:28)
    at TLSSocket.socketErrorListener (node:_http_client:501:9)
    at TLSSocket.emit (node:events:529:35)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

I, [2025-01-14T10:21:45.402602 #1]  INFO -- : Terminating async processes
I, [2025-01-14T10:21:45.402652 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 39
107:signal-handler (1736850105) Received SIGTERM scheduling shutdown...
I, [2025-01-14T10:21:45.402684 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 107
2025-01-14 10:21:45.402 UTC [39] LOG:  received fast shutdown request
2025-01-14 10:21:45.404 UTC [39] LOG:  aborting any active transactions
2025-01-14 10:21:45.406 UTC [39] LOG:  background worker "logical replication launcher" (PID 54) exited with exit code 1
2025-01-14 10:21:45.407 UTC [49] LOG:  shutting down
2025-01-14 10:21:45.431 UTC [39] LOG:  database system is shut down
107:M 14 Jan 2025 10:21:45.436 # User requested shutdown...
107:M 14 Jan 2025 10:21:45.436 * Saving the final RDB snapshot before exiting.
107:M 14 Jan 2025 10:21:45.441 * DB saved on disk
107:M 14 Jan 2025 10:21:45.441 # Redis is now ready to exit, bye bye...


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && if [ -f yarn.lock ]; then
  if [ -d node_modules/.pnpm ]; then
    echo "This version of Discourse uses yarn, but pnpm node_modules are preset. Cleaning up..."
    find ./node_modules ./app/assets/javascripts/*/node_modules -mindepth 1 -maxdepth 1 -exec rm -rf {} +
  fi
  su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'
else
  su discourse -c 'CI=1 pnpm install --frozen-lockfile && pnpm prune'
fi failed with return #<Process::Status: pid 301 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"yarn", "cmd"=>["if [ -f yarn.lock ]; then\n  if [ -d node_modules/.pnpm ]; then\n    echo \"This version of Discourse uses yarn, but pnpm node_modules are preset. Cleaning up...\"\n    find ./node_modules ./app/assets/javascripts/*/node_modules -mindepth 1 -maxdepth 1 -exec rm -rf {} +\n  fi\n  su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'\nelse\n  su discourse -c 'CI=1 pnpm install --frozen-lockfile && pnpm prune'\nfi"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
58bc76b977b8eb7c806f0308caacabe389605c6242852e8f17c30076b728de67

실패 원인은 중국 본토의 네트워크 제한으로 인해 패키지나 의존성(예: GitHub 또는 npm에서)을 가져올 수 없기 때문인 것으로 보입니다.

시도해 본 방법

프록시 사용: Shell Clash을 사용하여 프록시 서버를 설정하려고 시도했으며, 구글(보통 중국 본토에서는 접근이 불가능한 사이트)에 성공적으로 접근했습니다. 테스트 출력은 다음과 같습니다:

root@lavm-hypge0pc5w:/var/discourse# sudo wget google.com
--2025-01-14 18:35:22--  http://google.com/
Resolving google.com (google.com)... 198.18.0.5
Connecting to google.com (google.com)|198.18.0.5|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.google.com/ [following]
--2025-01-14 18:35:22--  http://www.google.com/
Resolving www.google.com (www.google.com)... 198.18.0.6
Connecting to www.google.com (www.google.com)|198.18.0.6|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html.2’

index.html.2                                       [ <=>                                                                                              ]  19.38K  --.-KB/s    in 0.05s   

2025-01-14 18:35:22 (372 KB/s) - ‘index.html.2’ saved [19841]

root@lavm-hypge0pc5w:/var/discourse# 

그러나 ./launcher rebuild app을 실행한 후에도 여전히 이전과 동일한 오류가 발생합니다.

질문

중국 본토에 위치한 서버에서 Discourse를 성공적으로 배포할 수 있는 방법이 있을까요?

Hi :slight_smile:

Have you looked at 🇨🇳 Discourse Official Install Guide | Discourse 云平台安装? It covers typical issues when installing Discourse in Mainland China.

Yes, I’ve seen this post. It’s essentially a Chinese translation of INSTALL-cloud.md

My issue was resolved by adding the following line to my app.yaml file:
- "templates/web.china.template.yml"

If you’re facing a similar issue, you might find this article helpful: Discourse Installation Guide.

It covers parts specific to China, such as the issue you faced:

I totally missed that line. thanks a ton!