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

Thank you so much for your response @pfaffman, I really appreciate it.

Digging deeper into this, I’ve tried to revert all the changes in /etc/nginx/conf.d/discourse.conf inside the container, entering into it with /var/discourse/launcher enter app.
After reverting the discourse.conf file I did a rebuild, using /var/discourse/launcher rebuild app.
I’ve tried to access to the website, without /forum but the same "Oops " error appear (the first image I attached in my previous comment).

Also, I’ve tried to execute (inside the container):

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

inside the container, but another error has appeared (I think is the same that @ahmed_khan1 has highlighted):

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)

So I’m not sure what more I can do :confused:

「いいね!」 1

nginx/discourse.conf の編集方法

再構築を行うと、コンテナ内の discourse.conf に対する変更はすべて元に戻されると想定されます。

変更を保持するには、コンテナ構成に何らかの方法で追加する必要があります。たとえば、web_only.yml に追加します。

# [...]
## YAML構文であることを忘れないでください。名前付きブロックは1つしか使用できません。
run:
  - exec: echo "カスタムコマンドの開始"
# [...]
  - 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 Web コンテナの Nginx]

したがって、エラーが発生した場合は、まず特定する必要があります。

  • 外部プロキシ
  • Discourse コンテナの Nginx
  • Discourse 自体

外部プロキシ

  • ブラウザで呼び出して結果を確認します。
  • 外部プロキシのエラーログを確認します。

Discourse コンテナの Nginx

  1. Web サーバーに SSH で接続します。
  2. curl を使用してソケットに直接接続します。
  3. curl の出力と Discourse コンテナの Nginx のログをデバッグします。

重要: https ではなく http URL を使用してください。

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

He @pfaffman and @rrit,

I have some more insights about the problem. In the Discourse log, as @pfaffman said:

the error thrown is:

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

Is this ringing a bell for you?

Btw, @rrit I’ve tried to search the nginx.http.sock file, in the folder you suggested and also in the whole project, but I didn’t found, so I was not able to try what you said :confused:

Regards,
Miguel.
He @pfaffman and @rrit,

I have some more insights about the problem. In the Discourse log, as @pfaffman said:

the error thrown is:

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

Is this ringing a bell for you?

Btw, @rrit I’ve tried to search the nginx.http.sock file, in the folder you suggested and also in the whole project, but I didn’t found, so I was not able to try what you said :confused:

Regards,
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

私の場合は、そのままにしておくと、nginxのログではユーザーIPが正しく記録されていたにもかかわらず、すべてのユーザーで127.0.0.1と表示されていました。

@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 コマンドでインストールしました。Gem についてはあまり詳しくありません。これを実行するために他にインストールする必要があるものはありますか?

「いいね!」 1

コンテナ内でコマンドを実行する必要があります

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

最後の cd は不要かもしれません。

「いいね!」 2