خدمة Discourse من مجلد فرعي (بادئة مسار) بدلاً من النطاق الفرعي

:warning: Discourse Official Statement about Subfolder setup

We support subfolder setups for our hosted customers at the enterprise level and up. Due to heavy technical setup complexity we strongly recommend you do not use this setup unless you are very experienced in custom subfolder setups.

It is critical you have a deep understanding of

  • NGINX setup in the Discourse Docker container
  • Secure original IP forwarding using custom headers in the proxy chain
  • Rate limiting in front proxy server

If this all sounds odd and strange to you we strongly recommend you avoid this setup.

To serve Discourse from a subfolder (a.k.a. with a path prefix) on your domain, like https://www.example.com/=SUBFOLDER=, here’s how to do it!

Docker config

In the env section of your docker container yml file, add the DISCOURSE_RELATIVE_URL_ROOT setting with the subfolder you want to use. Make sure it does not end with a /.

Editing this will update the entire guide.

env:
  ...
  DISCOURSE_RELATIVE_URL_ROOT: /=SUBFOLDER=

The run section needs some changes to send all Discourse routes to the right place. Here is a complete run section with subfolder support:

run:
    - exec:
        cd: $home
        cmd:
          - mkdir -p public/=SUBFOLDER=
          - cd public/=SUBFOLDER= && ln -s ../uploads && ln -s ../backups
    - replace:
       global: true
       filename: /etc/nginx/conf.d/discourse.conf
       from: proxy_pass http://discourse;
       to: |
          rewrite ^/(.*)$ /=SUBFOLDER=/$1 break;
          proxy_pass http://discourse;
    - replace:
       filename: /etc/nginx/conf.d/discourse.conf
       from: etag off;
       to: |
          etag off;
          location /=SUBFOLDER= {
             rewrite ^/=SUBFOLDER=/?(.*)$ /$1;
          }
    - replace:
         filename: /etc/nginx/conf.d/discourse.conf
         from: $proxy_add_x_forwarded_for
         to: $http_your_original_ip_header
         global: true

$http_your_original_ip_header stands for Your-Original-Ip-Header, which is a trusted Header you set on the origin which contains the actual client IP.

This is required cause traffic passes through a central proxy, if Discourse happens to have a public IP you can spoof it. If Discourse is private you may be able to get away with X-Forwarded-For

After making these changes, bootstrap your Docker container as usual, or rebuild if you’re changing an existing container.

./launcher bootstrap app

or

./launcher rebuild app

Attached is a complete example yml file of a standalone container.

subfolder-sample.yml (3.1 KB)

Rate limiting concerns

If you are going for this setup you probably want to rate limit requests prior to them landing on NGINX in the container, that means you probably will avoid using our rate limiting template. It is very hard to configure NGINX in the container to limit on a remapped IP and would require complex changes to the template.

Existing posts

If you did this with an existing site that was on a subdomain, you’ll find that your uploads are broken. There’s a tool that can help fix all paths to include the subfolder. In the Discourse directory (typically /var/www/discourse'), run it like this after taking a backup:

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

See also: Use a subfolder (path prefix) to serve Discourse with multiple servers sharing a domain for more esoteric setups.

robots.txt

Now that Discourse is running on a subfolder, it cannot serve its robots.txt file to control which routes are crawled by web crawlers. Crawlers will be looking at your main site’s robots.txt file (https://www.example.com/robots.txt). You need to copy the contents of Discourse’s robots.txt file (found at https://www.example.com/=SUBFOLDER=/robots.txt) and put it in your main site’s robots.txt file.

Last edited by @JammyDodger 2024-05-25T11:29:05Z

Check documentPerform check on document:
35 إعجابًا

:warning: Please discuss the merits of subfolder vs non-subfolder on separate topics.

Any discussion about the subfolder setup here will likely be integrated into the top post and deleted.

I just edited the OP with more warnings!

10 إعجابات

That remap command wouldn’t work unless I called bundle exec discourse instead of bundle exec script/discourse.

I had to update the external_system_avatars_url site setting, and found I had to also remap things like <subfolder>/user_avatar/<domain>, <subfolder>/plugins, <subfolder>/images, etc…

3 إعجابات

Thanks for mentioning that @vvanpo :slight_smile:

I managed to get this working but do not know where to link <subfolder>/user_avatar/<domain>.

There is no user_avatar folder in the public folder. Where have you pointed (dest) your user_avatar symbolic link placed into <subfolder> ?

Thanks :wink:

Edit: It seems to work without user_avatar link. Maybe images must be rebuilded in background (sidekiq tasks) and this just take some time.

إعجاب واحد (1)

thanks @vvanpo

here’s what worked for me:

RAILS_ENV=production bundle exec discourse remap '/uploads' '/<subfolder>/uploads'
RAILS_ENV=production bundle exec discourse remap '/user_avatar/<domain>' '/<subfolder>/user_avatar/<domain>'
RAILS_ENV=production bundle exec discourse remap '/images' '/<subfolder>/images'
RAILS_ENV=production bundle exec discourse remap '/plugins' '/<subfolder>/plugins'
3 إعجابات

Considering the rewrite only matches with the subfolder trailing slash, I think it’s safe to change the location directive to /forum/ in this howto, avoiding a possible clash if there are routes starting with the subfolder string. What do you think?

everything went fine while installing but when I was executing this command

after doing ./launcher enter app I got an error
im using ubuntu

root@ahmed-app:/var/www/discourse# RAILS_ENV=production bundle exec script/discourse remap '/uploads' '/ask/uploads'
bundler: failed to load command: script/discourse (script/discourse)
Traceback (most recent call last):
        77: from /usr/local/bin/bundle:23:in `<main>'
        76: from /usr/local/bin/bundle:23:in `load'
        75: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/exe/bundle:37:in `<top (required)>'
        74: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
        73: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/exe/bundle:49:in `block in <top (required)>'
        72: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli.rb:24:in `start'
        71: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        70: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli.rb:30:in `dispatch'
        69: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        68: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        67: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        66: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli.rb:494:in `exec'
        65: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli/exec.rb:28:in `run'
        64: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli/exec.rb:63:in `kernel_load'
        63: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli/exec.rb:63:in `load'
        62: from script/discourse:286:in `<top (required)>'
        61: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
        60: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        59: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
        58: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
        57: from script/discourse:33:in `remap'
        56: from script/discourse:266:in `load_rails'
        55: from script/discourse:266:in `require'
        54: from /var/www/discourse/config/environment.rb:7:in `<top (required)>'
        53: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/railtie.rb:190:in `method_missing'
        52: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/railtie.rb:190:in `public_send'
        51: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/application.rb:363:in `initialize!'
        50: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:60:in `run_initializers'
        49: from /usr/local/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
        48: from /usr/local/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
        47: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
        46: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `call'
        45: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each'
        44: from /usr/local/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
        43: from /usr/local/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
        42: from /usr/local/lib/ruby/2.7.0/tsort.rb:415:in `call'
        41: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:50:in `tsort_each_child'
        40: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:50:in `each'
        39: from /usr/local/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
        38: from /usr/local/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
        37: from /usr/local/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
        36: from /usr/local/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        35: from /usr/local/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
        34: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:61:in `block in run_initializers'
        33: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:32:in `run'
        32: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:32:in `instance_exec'
        31: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:624:in `block in <class:Engine>'
        30: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:624:in `each'
        29: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:625:in `block (2 levels) in <class:Engine>'
        28: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:665:in `load_config_initializer'
        27: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/notifications.rb:182:in `instrument'
        26: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:666:in `block in load_config_initializer'
        25: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:318:in `load'
        24: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:291:in `load_dependency'
        23: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:318:in `block in load'
        22: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
        21: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
        20: from /var/www/discourse/config/initializers/004-message_bus.rb:120:in `<main>'
        19: from /var/www/discourse/lib/site_setting_extension.rb:522:in `block in setup_methods'
        18: from /var/www/discourse/lib/site_setting_extension.rb:287:in `refresh!'
        17: from /var/www/discourse/lib/site_setting_extension.rb:287:in `synchronize'
        16: from /var/www/discourse/lib/site_setting_extension.rb:290:in `block in refresh!'
        15: from /var/www/discourse/lib/site_settings/defaults_provider.rb:29:in `db_all'
        14: from /var/www/discourse/lib/site_settings/db_provider.rb:16:in `all'
        13: from /var/www/discourse/lib/site_settings/db_provider.rb:61:in `table_exists?'
        12: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_handling.rb:189:in `connection'
        11: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_handling.rb:221:in `retrieve_connection'
        10: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in `retrieve_connection'
         9: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection'
         8: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout'
         7: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection'
         6: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection'
         5: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection'
         4: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection'
         3: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:46:in `postgresql_connection'
         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': FATAL:  Peer authentication failed for user "discourse" (PG::ConnectionBad)
        75: from /usr/local/bin/bundle:23:in `<main>'
        74: from /usr/local/bin/bundle:23:in `load'
        73: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/exe/bundle:37:in `<top (required)>'
        72: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
        71: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/exe/bundle:49:in `block in <top (required)>'
        70: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli.rb:24:in `start'
        69: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        68: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli.rb:30:in `dispatch'
        67: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        66: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        65: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        64: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli.rb:494:in `exec'
        63: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli/exec.rb:28:in `run'
        62: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli/exec.rb:63:in `kernel_load'
        61: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli/exec.rb:63:in `load'
        60: from script/discourse:286:in `<top (required)>'
        59: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
        58: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        57: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
        56: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
        55: from script/discourse:33:in `remap'
        54: from script/discourse:266:in `load_rails'
        53: from script/discourse:266:in `require'
        52: from /var/www/discourse/config/environment.rb:7:in `<top (required)>'
        51: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/railtie.rb:190:in `method_missing'
        50: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/railtie.rb:190:in `public_send'
        49: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/application.rb:363:in `initialize!'
        48: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:60:in `run_initializers'
        47: from /usr/local/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
        46: from /usr/local/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
        45: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
        44: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `call'
        43: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each'
        42: from /usr/local/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
        41: from /usr/local/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
        40: from /usr/local/lib/ruby/2.7.0/tsort.rb:415:in `call'
        39: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:50:in `tsort_each_child'
        38: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:50:in `each'
        37: from /usr/local/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
        36: from /usr/local/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
        35: from /usr/local/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
        34: from /usr/local/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        33: from /usr/local/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
        32: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:61:in `block in run_initializers'
        31: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:32:in `run'
        30: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:32:in `instance_exec'
        29: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:624:in `block in <class:Engine>'
        28: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:624:in `each'
        27: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:625:in `block (2 levels) in <class:Engine>'
        26: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:665:in `load_config_initializer'
        25: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/notifications.rb:182:in `instrument'
        24: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:666:in `block in load_config_initializer'
        23: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:318:in `load'
        22: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:291:in `load_dependency'
        21: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:318:in `block in load'
        20: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
        19: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
        18: from /var/www/discourse/config/initializers/004-message_bus.rb:120:in `<main>'
        17: from /var/www/discourse/lib/site_setting_extension.rb:522:in `block in setup_methods'
        16: from /var/www/discourse/lib/site_setting_extension.rb:287:in `refresh!'
        15: from /var/www/discourse/lib/site_setting_extension.rb:287:in `synchronize'
        14: from /var/www/discourse/lib/site_setting_extension.rb:290:in `block in refresh!'
        13: from /var/www/discourse/lib/site_settings/defaults_provider.rb:29:in `db_all'
        12: from /var/www/discourse/lib/site_settings/db_provider.rb:16:in `all'
        11: from /var/www/discourse/lib/site_settings/db_provider.rb:61:in `table_exists?'
        10: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_handling.rb:189:in `connection'
         9: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_handling.rb:221:in `retrieve_connection'
         8: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in `retrieve_connection'
         7: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection'
         6: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout'
         5: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection'
         4: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection'
         3: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection'
         2: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection'
         1: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:33:in `postgresql_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:50:in `rescue in postgresql_connection': FATAL:  Peer authentication failed for user "discourse" (ActiveRecord::NoDatabaseError)

its works for me too

After following the above-mentioned steps to use discourse in a subfolder, now am getting a new error posted below :

Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Because of this error, the CSS files of the discourse are not loading and the page is blank. Can someone please help me with this?

Hi, my forum is installed on community.example.com now i want it to move on example.com/community (forum is already ruining) now i have added the env section and run section to yml , can someone answer my queries

  1. What will i add in $http_your_original_ip_header ?
  2. The old domain is community.example.com in DISCOURSE_HOSTNAME: do i have to change it ?
  3. What will be "proxy_pass http://discourse; " section in run
إعجاب واحد (1)

Nothing, that should be copied as written.

That should also be copied as written

Yes, it should now be example.com

5 إعجابات

After many rebuild it is working fine now , just small issue SSL is not working , Not using any ssl template how to get SSL working

إعجاب واحد (1)

Did you set the LETSENCRYPT_ACCOUNT_EMAIL?

Also, if you have rebuilt more than five (?) times, you’ve got the rate limit and won’t be able to get a certificate for that domain name for a week.

3 إعجابات

تجربتي:

force https -> checked

كان عليّ أيضًا وكالة /assets إلى subfolder/assets وإلا فسيتم طرح 404 لـ *.js.map

… وبالطبع $http_your_original_ip_header من المفترض أن يكون $proxy_add_x_forwarded_for افتراضيًا.

4 إعجابات

مرحباً،

هل حاول أي شخص التراجع عن تكوين المجلد الفرعي لمثيل Discourse قيد التشغيل؟

لقد قمت بتكوين مثيل لاستخدام هذا التكوين، لمجلد فرعي مثل /forum، وقد نجح ذلك. لكننا قررنا في النهاية استخدام خيار النطاق الفرعي، لذلك حاولت التراجع عن جميع التغييرات، وهذا هو، إزالة متغير DISCOURSE_RELATIVE_URL_ROOT وقسم run، وكتابة الإعداد الافتراضي:

run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"

وعند إعادة بناء التطبيق، يتم عرض الشاشة التالية عند محاولة الوصول إلى عنوان URL (بدون /forum):

وإذا حاولت الانتقال إلى /forum، يتم عرض الشاشة التالية:

لذلك لا أعرف ما هي التغييرات الأخرى المطلوبة لجعله يعمل مرة أخرى.

مع خالص التقدير،
ميغيل.

إعجاب واحد (1)

ما كنت سأفعله هو النسخ الاحتياطي والاستعادة إلى خادم جديد. هذا كان سيترك خادمك الحالي يعمل حتى تتمكن من اختبار الخادم الجديد. وبما أنه على نطاق فرعي جديد، كان سيكون من الأسهل بكثير القيام بذلك بهذه الطريقة. لكن هذا لا يساعدك.

هل قمت بهذه الخطوة بالعكس؟

أعتقد أنك ستحتاج إلى القيام بذلك

RAILS_ENV=production bundle exec script/discourse remap ‘/forum/uploads’ ‘/uploads’

لكن هذا لا يفسر خطأ “Oops”. المكان الذي يجب البحث فيه هو السجلات في

/var/discourse/shared/standalone/logs/var-log/nginx/

و

/var/discourse/shared/standalone/logs/rails/production.log

لقد كتبت كلا هذين، لذلك قد تحتاج إلى تعديل الأشياء إذا أخطأت.

يسعدني المساعدة هنا قدر الإمكان، ولكن إذا كان هذا يعتبر حالة طوارئ لديك ميزانية لها، يمكنك الاتصال بي مباشرة.

3 إعجابات

كيفية عمل تسجيل الدخول الاجتماعي، أعني الآن ما هو عنوان URI للمعاودة للاتصال المصرح به
DISCOURSE_HOSTNAME: example.com
DISCOURSE_RELATIVE_URL_ROOT: /forum
هل سيكون example.com أم forum.example.com أم example.com/forum (google و fb لا يقبلان هذا الرابط)

إعجاب واحد (1)

وفقًا لـ تكوين تسجيل الدخول إلى فيسبوك لـ Discourse
عنوان URL للرد هو https://discourse.example.com/auth/facebook/callback بالنسبة لمجلد فرعي سيكون https://discourse.example.com/forum/auth/facebook/callback

إعجابَين (2)

ذهب التطبيق بشكل جيد ولكن بعد ذلك فشل https://example.com/community/auth/failure?message=no_authorization_code&origin=https%3A%2F%2Fexample.com%2Fcommunity%2F&strategy=facebook#_= _

عذرًا، حدث خطأ أثناء المصادقة على حسابك. يُرجى المحاولة مرة أخرى.

أنا متأكد من أن هذا يعني أن لديك جزء المجلد الفرعي تم بشكل صحيح وتحتاج الآن إلى إصلاح جزء فيسبوك، وهو أكثر صعوبة بكثير.

إعجاب واحد (1)