Serve Discourse from a subfolder (path prefix) instead of a subdomain

@pfaffman 님, 답변 주셔서 정말 감사합니다.

이 문제를 더 깊이 파고들어 보려고 컨테이너에 /var/discourse/launcher enter app 명령으로 접속하여 /etc/nginx/conf.d/discourse.conf 파일 안의 모든 변경 사항을 되돌려 보았습니다.
discourse.conf 파일을 되돌린 후 /var/discourse/launcher rebuild app 명령을 사용하여 재빌드(rebuild)를 수행했습니다.
/forum 경로 없이 웹사이트에 접속해 보았지만, 이전 댓글에 첨부한 첫 번째 이미지와 동일한 “Oops” 오류가 나타났습니다.

또한 컨테이너 안에서 다음 명령을 실행해 보았지만, 다른 오류가 발생했습니다(@ahmed_khan1 님이 지적한 것과 같은 오류인 것 같습니다):

RAILS_ENV=production bundle exec script/discourse remap '/forum/uploads' '/uploads' 
bundler: failed to load command: script/discourse (script/discourse)
Traceback (most recent call last):
	73: from /usr/local/bin/bundle:25:in `<main>'
	72: from /usr/local/bin/bundle:25:in `load'
	71: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/exe/bundle:36:in `<top (required)>'
	70: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
	69: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/exe/bundle:48:in `block in <top (required)>'
	68: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:25:in `start'
	67: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	66: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:31:in `dispatch'
	65: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	64: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	63: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	62: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:484:in `exec'
	61: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:23:in `run'
	60: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:58:in `kernel_load'
	59: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:58:in `load'
	58: from script/discourse:290:in `<top (required)>'
	57: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
	56: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	55: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
	54: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	53: from script/discourse:37:in `remap'
	52: from script/discourse:270:in `load_rails'
	51: from script/discourse:270:in `require'
	50: from /var/www/discourse/config/environment.rb:7:in `<top (required)>'
	49: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `method_missing'
	48: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `public_send'
	47: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:391:in `initialize!'
	46: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:60:in `run_initializers'
	45: from /usr/local/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
	44: from /usr/local/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
	43: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
	42: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `call'
	41: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each'
	40: from /usr/local/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
	39: from /usr/local/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
	38: from /usr/local/lib/ruby/2.7.0/tsort.rb:415:in `call'
	37: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in `tsort_each_child'
	36: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in `each'
	35: from /usr/local/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
	34: from /usr/local/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
	33: from /usr/local/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
	32: from /usr/local/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	31: from /usr/local/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
	30: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
	29: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `run'
	28: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `instance_exec'
	27: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:633:in `block in <class:Engine>'
	26: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:633:in `each'
	25: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:634:in `block (2 levels) in <class:Engine>'
	24: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:680:in `load_config_initializer'
	23: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/notifications.rb:205:in `instrument'
	22: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:681:in `block in load_config_initializer'
	21: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:326:in `load'
	20: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
	19: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:326:in `block in load'
	18: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
	17: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
	16: from /var/www/discourse/config/initializers/004-message_bus.rb:122:in `<main>'
	15: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/model_schema.rb:380:in `table_exists?'
	14: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_handling.rb:283:in `connection'
	13: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
	12: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
	11: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
	10: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
	 9: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
	 8: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
	 7: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
	 6: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
	 5: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
	 4: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
	 3: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
	 2: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `connect'
	 1: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `new'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `initialize': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "discourse" (PG::ConnectionBad)
	71: from /usr/local/bin/bundle:25:in `<main>'
	70: from /usr/local/bin/bundle:25:in `load'
	69: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/exe/bundle:36:in `<top (required)>'
	68: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
	67: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/exe/bundle:48:in `block in <top (required)>'
	66: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:25:in `start'
	65: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	64: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:31:in `dispatch'
	63: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	62: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	61: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	60: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:484:in `exec'
	59: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:23:in `run'
	58: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:58:in `kernel_load'
	57: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:58:in `load'
	56: from script/discourse:290:in `<top (required)>'
	55: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
	54: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	53: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
	52: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	51: from script/discourse:37:in `remap'
	50: from script/discourse:270:in `load_rails'
	49: from script/discourse:270:in `require'
	48: from /var/www/discourse/config/environment.rb:7:in `<top (required)>'
	47: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `method_missing'
	46: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `public_send'
	45: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:391:in `initialize!'
	44: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:60:in `run_initializers'
	43: from /usr/local/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
	42: from /usr/local/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
	41: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
	40: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `call'
	39: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each'
	38: from /usr/local/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
	37: from /usr/local/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
	36: from /usr/local/lib/ruby/2.7.0/tsort.rb:415:in `call'
	35: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in `tsort_each_child'
	34: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in `each'
	33: from /usr/local/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
	32: from /usr/local/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
	31: from /usr/local/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
	30: from /usr/local/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	29: from /usr/local/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
	28: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
	27: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `run'
	26: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `instance_exec'
	25: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:633:in `block in <class:Engine>'
	24: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:633:in `each'
	23: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:634:in `block (2 levels) in <class:Engine>'
	22: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:680:in `load_config_initializer'
	21: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/notifications.rb:205:in `instrument'
	20: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:681:in `block in load_config_initializer'
	19: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:326:in `load'
	18: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
	17: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:326:in `block in load'
	16: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
	15: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
	14: from /var/www/discourse/config/initializers/004-message_bus.rb:122:in `<main>'
	13: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/model_schema.rb:380:in `table_exists?'
	12: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_handling.rb:283:in `connection'
	11: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
	10: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
	 9: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
	 8: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
	 7: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
	 6: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
	 5: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
	 4: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
	 3: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
	 2: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
	 1: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:81:in `rescue in new_client': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "discourse" (ActiveRecord::NoDatabaseError)

그래서 더 무엇을 해야 할지 모르겠습니다 :confused:

1개의 좋아요

nginx/discourse.conf 편집 방법

컨테이너 내부의 discourse.conf에 대한 변경 사항은 재빌드를 수행하면 어쨌든 되돌려진다고 가정합니다.

변경 사항을 유지하려면 컨테이너 설정(예: web_only.yml)에 해당 내용을 어떻게든 추가해야 합니다:

# […]
## 참고: 이는 YAML 문법입니다 - 이름이 있는 블록은 하나만 가질 수 있습니다
run:
  - exec: echo "Beginning of custom commands"
# […]
  - replace:
      filename: /etc/nginx/conf.d/discourse.conf
      from: $proxy_add_x_forwarded_for
      to: $http_x_real_ip
      global: true
# […]

서브폴더 Discourse 설치 디버깅 방법

Discourse 서브폴더 설치에서 Discourse 호출은 다음과 같이 이루어집니다:
example.org/forum → [example.org용 외부 프록시] → /path-to-discourse/discourse/shared/web-only/nginx.http.sock → [Discourse 웹 컨테이너 내 Nginx]

따라서 오류가 발생하면 먼저 오류 위치를 파악해야 합니다:

  • 외부 프록시
  • Discourse 컨테이너 내 Nginx
  • Discourse 자체

외부 프록시

  • 브라우저에서 호출하여 결과를 확인합니다.
  • 외부 프록시의 오류 로그를 확인합니다.

Discourse 컨테이너 내 Nginx

  1. 웹서버에 SSH로 접속합니다.
  2. curl을 사용하여 소켓에 직접 연결합니다.
  3. curl 출력 및 Nginx in Discourse의 로그를 디버깅합니다.

중요: http URL을 사용해야 하며 https를 사용해서는 안 됩니다.

curl -I --unix-socket /path-to-discourse/discourse/shared/web-only/nginx.http.sock http://www.example.org/forum/

이것이 작동하면 다음과 같은 실제 호출을 시도해 보세요:

curl --unix-socket /path-to-discourse/discourse/shared/web-only/nginx.http.sock \
-H "user-agent: Chrome/88.0.4324.182" \
-H "Accept-Encoding: gzip" \
http://www.example.org/forum/t/test-thread/12345 --output test-encoded.html.gz
3개의 좋아요

@pfaffman 님과 @rrit 님께,

이 문제에 대해 몇 가지 추가 통찰을 얻었습니다. @pfaffman 님이 말씀하신 대로 Discourse 로그에서:

발생하는 에러는 다음과 같습니다:

Started GET "/" for XX.XX.XX.XX at 2022-02-07 10:51:02 +0000
Processing by ListController#latest as HTML
  Rendered list/list.erb within layouts/application (Duration: 12.4ms | Allocations: 4137)
  Rendered layout layouts/application.html.erb (Duration: 23.6ms | Allocations: 8794)
Completed 500 Internal Server Error in 343ms (ActiveRecord: 0.0ms | Allocations: 62982)
ActionView::Template::Error (undefined method `[]' for nil:NilClass)
lib/svg_sprite/svg_sprite.rb:501:in `block in custom_icons'
lib/svg_sprite/svg_sprite.rb:500:in `each'
lib/svg_sprite/svg_sprite.rb:500:in `custom_icons'
lib/svg_sprite/svg_sprite.rb:275:in `block in all_icons'
lib/distributed_cache.rb:25:in `defer_get_set'
lib/svg_sprite/svg_sprite.rb:516:in `get_set_cache'
lib/svg_sprite/svg_sprite.rb:268:in `all_icons'
lib/svg_sprite/svg_sprite.rb:337:in `bundle'
lib/svg_sprite/svg_sprite.rb:285:in `block in version'
lib/distributed_cache.rb:25:in `defer_get_set'
lib/svg_sprite/svg_sprite.rb:516:in `get_set_cache'
lib/svg_sprite/svg_sprite.rb:284:in `version'
lib/svg_sprite/svg_sprite.rb:290:in `path'
app/helpers/application_helper.rb:586:in `client_side_setup_data'
app/views/layouts/application.html.erb:61
lib/topic_list_responder.rb:13:in `block (2 levels) in respond_with_list'
lib/topic_list_responder.rb:9:in `respond_with_list'
app/controllers/list_controller.rb:103:in `block (2 levels) in <class:ListController>'
app/controllers/application_controller.rb:387:in `block in with_resolved_locale'
app/controllers/application_controller.rb:387:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:356:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'
ActionController::RoutingError (No route matches [GET] "/service-worker-cce5f3834b22e40a87291d786315f7def48e1456ba24fe116a16d5a38af4012a.js")
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'
ActionController::RoutingError (No route matches [GET] "/service-worker-cce5f3834b22e40a87291d786315f7def48e1456ba24fe116a16d5a38af4012a.js")
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'
Job exception: uninitialized constant DiscourseAlgolia::UserIndexer::SETTINGS
Did you mean?  String

이것이 여러분에게 익숙한 문제인가요?

참고로, @rrit 님, 제안해 주신 폴더와 프로젝트 전체에서 nginx.http.sock 파일을 검색해 보았지만 찾지 못했습니다. 그래서 말씀하신 내용을 시도해 볼 수 없었습니다 :confused:

감사합니다,
Miguel.

1개의 좋아요

이건 도대체 뭘 하신 건지, 아니면 뭘 하려는지 정확히 파악하기 어렵네요.

마지막으로 정상 작동하던 데이터베이스와 yml 파일의 백업이 없으신 건가요?

제가 하라면, 마지막으로 정상 작동하던 설정으로 되돌린 뒤 백업을 하고, 테스트 사이트에서 처음부터 다시 시작해 볼 거예요.

1개의 좋아요

죄송합니다. 다음과 같은 설정을 염두에 두고 있었습니다:

컨테이너 설정 web_only.yml:

templates:
# […]
  - "templates/web.socketed.template.yml"
# […]
#expose:
#  - "80:80"   # http
#  - "443:443" # https

외부 nginx-site.conf:

server {
    listen 443 ssl default_server;
# […]
    location ~ ^/forum {
        proxy_pass http://unix:/path-to-discourse/discourse/shared/web-only/nginx.http.sock:;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Accept-Encoding $http_accept_encoding;
    }
# […]
}
2개의 좋아요

@pfaffman 님, 답변해 주셔서 감사합니다. 솔직히 말하면 테스트 인스턴스였기 때문에 백업이 없습니다. 그래서 큰 문제는 아니었고, 서브도메인 방식으로 새로운 인스턴스를 시작할 수 있었습니다.
하지만 해당 명령을 실행할 때 말씀드린 오류에 대해 여전히 궁금합니다:

RAILS_ENV=production bundle exec script/discourse remap '/forum/uploads' '/uploads'

이 오류에 대해 어떤 통찰을 주실 수 있을까요?

1개의 좋아요

즉, 서브폴더 설치와 서브폴더가 아닌 설치 사이를 자유롭게 전환할 수 있기를 원하시는 건가요? 그렇게 하지는 않는 것을 권장합니다. 대부분의 사람들이 서브폴더 설치가 좋은 방법이라고 생각하지도 않습니다.

2개의 좋아요

제 경우, 그대로 두니 모든 사용자에게 127.0.0.1로 표시되었습니다. nginx 로그에는 사용자 IP가 올바르게 기록되어 있었음에도 말이죠.

@varun21 님의 답변 Serve Discourse from a subfolder (path prefix) instead of a subdomain - #111 by varun21 을 적용하니 문제가 해결되었습니다.

@varun21 님 감사합니다.

2개의 좋아요

이 가이드를 올려주셔서 감사합니다! /var/discourse 폴더에서 이 명령어를 실행하면:

RAILS_ENV=production bundle exec script/discourse remap '/uploads' '/forum/uploads'

다음과 같은 오류가 발생합니다:

Could not locate Gemfile or .bundle/ directory

Ruby는 snap install ruby --classic 명령어로 설치했습니다. Gems에 대해 잘 모릅니다. 이 명령어를 실행하려면 추가로 무엇을 설치해야 하는지 알려주실 수 있을까요?

1개의 좋아요

명령어를 컨테이너 내부에서 실행해야 합니다.

cd /var/discourse 
./launcher enter app 
cd /var/www/discourse 

마지막 cd는 필요하지 않을 것 같습니다.

2개의 좋아요

얼마 전부터 컨테이너에서 X-Accel-Mapping header missing 메시지가 상당히 높은 빈도로 출력되고 있습니다. 단, 모든 방문자나 모든 내비게이션 단계에서 발생하는 것은 아닙니다. 해당 헤더가 Nginx 설정에 명시적으로 정의되어 있긴 하지만 모든 요청에 대해 설정된 것은 아니라는 점을 확인했습니다: discourse/config/nginx.sample.conf at main · discourse/discourse · GitHub

이 포럼에서 다른 곳에서 이 문제가 보고된 것을 볼 수 없어, 우리가 사용하는 서브디렉터리(subdir) 설정과 관련이 있을 수 있다고 의심해 보지만, 그 연결고리는 명확하지 않습니다.

정확히 어떤 부분이 이 메시지를 출력하는지 확실하지는 않지만, X-Sendfile-Type이 X-Accel-Redirect로 설정되어 있고 X-Accel-Mapping이 설정되지 않은 경우에만 이런 일이 일어나야 한다고 추측합니다. 그런데 설정 파일에는 두 헤더가 모두 정의되어 있거나, 모두 비어 있는 경우만 존재합니다 :thinking:.

사실 이 메시지는 백업에 접근하거나, 더 관련이 깊은 부분으로, 업로드 파일에 접근할 때만 설정됩니다. 직접 테스트해 보니 업로드된 이미지 등이 포함된 게시물을 볼 때마다 해당 메시지가 트리거되는 것을 확인했습니다. 설정을 살펴보면 X-Accel-Redirect는 설정되어 있고 X-Accel-Mapping이 설정되지 않은 상태는 불가능해 보입니다. 또한 이는 컨테이너 내부에서 Nginx가 설정하고 Discourse/unicorn/pitchfork/백엔드만 소비하는 요청 헤더이므로, 컨테이너를 빠져나갔다 들어오는 것이 아닙니다.

아, 우리는 Nginx가 STDERR로 로그를 기록하도록 설정해 두었고, Discourse 로그에서 이 메시지를 볼 수 없으므로 Nginx 자체에서 이 메시지를 출력하는 것임을 확신합니다. 이것이 다른 누군가에게 인지되지 않은 이유일 수 있으며, Nginx 로그 파일에 기록되어 있기 때문입니다. 다른 분들도 shared/*/log/var-log/nginx/error.log 파일에 동일한 메시지가 있는지 확인해 주실 수 있을까요? 만약 그렇다면, 서브디렉터리 설정을 사용하지 않는 다른 사용자들에게도 확인하여 원인을 좁혀 나가보겠습니다.