Servire Discourse da una sottocartella (prefisso percorso) invece che da un sottodominio

:warning: Dichiarazione ufficiale di Discourse sulla configurazione in sottocartella

Supportiamo le configurazioni in sottocartella per i nostri clienti enterprise e superiori. A causa della complessità tecnica elevata, ti consigliamo vivamente di non utilizzare questa configurazione a meno che tu non sia molto esperto in configurazioni personalizzate di sottocartelle.

È fondamentale avere una profonda comprensione di

  • Configurazione NGINX nel container Docker di Discourse
  • Instradamento IP originale sicuro utilizzando intestazioni personalizzate nella catena del proxy
  • Limitazione della velocità (Rate limiting) nel server proxy anteriore

Se tutto questo ti suona strano, ti consigliamo vivamente di evitare questa configurazione.

Per servire Discourse da una sottocartella (alias con prefisso di percorso) sul tuo dominio, come https://www.example.com/=SUBFOLDER=, ecco come fare!

Configurazione Docker

Nella sezione env del tuo file yml del container docker, aggiungi l’impostazione DISCOURSE_RELATIVE_URL_ROOT con la sottocartella che desideri utilizzare. Assicurati che non finisca con uno /.

La modifica di questo aggiornerà l’intera guida.

env:
  ...
  DISCOURSE_RELATIVE_URL_ROOT: /=SUBFOLDER=

La sezione run necessita di alcune modifiche per inviare tutte le route di Discourse al posto giusto. Ecco una sezione run completa con supporto per sottocartelle:

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 sta per Your-Original-Ip-Header, che è un Header fidato che imposti sull’origine che contiene l’IP effettivo del client.

Questo è necessario perché il traffico passa attraverso un proxy centrale; se Discourse ha un IP pubblico, potresti essere in grado di falsificarlo. Se Discourse è privato, potresti cavartela con X-Forwarded-For.

Dopo aver apportato queste modifiche, avvia il tuo container Docker come al solito, o ricostruiscilo se stai modificando un container esistente.

./launcher bootstrap app

oppure

./launcher rebuild app

In allegato è disponibile un file yml di esempio completo per un container standalone.

subfolder-sample.yml (3.1 KB)

Preoccupazioni relative alla limitazione della velocità (Rate limiting)

Se stai optando per questa configurazione, probabilmente vorrai limitare la frequenza delle richieste prima che arrivino a NGINX nel container, il che significa che probabilmente eviterai di utilizzare il nostro template di limitazione della velocità. È molto difficile configurare NGINX nel container per limitare su un IP rimappato e richiederebbe modifiche complesse al template.

Post esistenti

Se lo hai fatto con un sito esistente che era su un sottodominio, scoprirai che i tuoi caricamenti sono interrotti. C’è uno strumento che può aiutare a correggere tutti i percorsi per includere la sottocartella. Prima, entra nel container Docker e naviga nella directory Discourse:

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

Quindi esegui il comando di rimappatura dopo aver effettuato un backup:

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

Vedi anche: Use a subfolder (path prefix) to serve Discourse with multiple servers sharing a domain per configurazioni più esoteriche.

robots.txt

Ora che Discourse è in esecuzione su una sottocartella, non può servire il suo file robots.txt per controllare quali route vengono sottoposte a scansione dai crawler web. I crawler cercheranno il file robots.txt del tuo sito principale (https://www.example.com/robots.txt). Devi copiare il contenuto del file robots.txt di Discourse (trovato su https://www.example.com/=SUBFOLDER=/robots.txt) e inserirlo nel file robots.txt del tuo sito principale.

35 Mi Piace
How can I change my installation from forum.website.com to www.website.com/forum?
Moving Discourse to subdirectory caused all uploads to break
Uploaded avatars and Gravatar not working with subfolder installation
Is it possible to install discourse inside a directory?
Launch Discourse on www.example.com/meta/ In a web folder type
Subfolder with SSL and nginx reverse proxy
404 errors (assets) on Subfolder installation
Uploaded avatar or gravatar not working
Install Discourse into domain.com/forums
Problem with discourse in a subfolder
Moving Discourse to subdirectory caused all uploads to break
Non-standard port breaks uploads
Avatar uploads broken on subfolder installs?
Image lightbox not working in subfolder install
Install Discourse as subfolder within Wordpress website?
Is it possible to install Discourse on the same domain of your main website
Subfolder install - external links get changed/redirected to site relative links
Discourse embedded on my WP
Reverse Proxy Assets
Reverse Proxy rewrites domain in external links in posts
Inheriting discourse install - need some assistance
Multisite installation ... in subdirectories?
Generals Subfolder recommendations and tips
Add to route headers?
Sorry, there was an error authorizing your account
Site Logo and Icons Break due to subfolder config
Site Logo and Icons Break due to subfolder config
Site Logo and Icons Break due to subfolder config
Running Discourse at / while serving a custom app at /tickets on the same domain
404 errors (assets) on Subfolder installation
404 errors (assets) on Subfolder installation
Moving Discourse from Subdomain to Subfolder
Blank Page After installing Discourse on Subfolder
Trailing slash and subfolder setup
Install Discourse as a subdirectory with existing Nginx
How to run discourse on subdirectory of external domain?
How to run discourse on subdirectory of external domain?
How to run discourse on subdirectory of external domain?
Digest email issue with 'stable'
Using other ports than 80 and 443 - HowTo?
Add secondary url / embed into Wordpress
Recent Changes Breaking Subfolder Setup?
Issue with FAQ link on edge case subfolder setup
Issue with FAQ link on edge case subfolder setup
Put discourse on a sub url
No subfolder prefixing for some resources
Upgrade failed - could use some help to try and fix using SSH
How to run Discourse in a subfolder?
Install Discourse without docker with an existing Rails app
Docker subfolder install not working due to Ember-CLI proxy error?
Multisite DISCOURSE_RELATIVE_URL_ROOT
How to install discourse into subdirectory instead of subdomain?
Setup wizard emoji wrong in subfolder install
Not find a Gravatar
Installing for production via Docker on existing server with Litespeed?
Use a subfolder (path prefix) to serve Discourse with multiple servers sharing a domain
Configure a Cloudfront reverse proxy for a subfolder install
Run other websites on the same machine as Discourse
Embedding Categories in Existing SPA
Does custom domain support the subpath format like 'example.com/forum'?
To use Discourse completely on shopify
Are separate subdomains required for making a discourse forum?
Problem when updating Discourse Forum
Domain missing from some requests after migration from subfolder back to subdomain
Error when I send a message in chat [downgraded to Stable from 3.1.0beta4]
Error when I send a message in chat [downgraded to Stable from 3.1.0beta4]
How to Change Discourse forum path
How to setup NGINX in the Discourse Docker container
How to setup NGINX in the Discourse Docker container
Possible to update add url path prefix for /t and /c
Implement the discourse forum in the laravel 11 project
Endless loading behind Cloudflare
Publish Discourse under URL
Cloudflare with subfolder setup
How to Set Up Discourse in a Subdirectory for Self-Hosting?
Setup wizard emoji wrong in subfolder install
National Flags
Discourse sign in redirects to root directory instead of subfolder
Last update breaks permalink for categories
Setup wizard emoji wrong in subfolder install
Ghost & Discourse SSO implementation
Wiki topics look incredibly out of date?
Too many redirects when reverse proxying to Discourse from a different server
Blank main page on one forum (subfolder + multisite install)
Moving Discourse to subdirectory caused all uploads to break
Feasible to reverse proxy using qualifier in URL?
Upgrade doesn't work when installed with subfolder
Setup Discourse with KeyCDN
Message bus does not respect subfolder during update process
Wiki Posts Not Green?
Base_url and base_uri
Embed whole Discourse board into Wordpresspage
Backup upload failing
Redirect to discourse from a route in another domain
Redirect to discourse from a route in another domain
Problem with discourse in a subfolder
Install Discourse as subfolder within Wordpress website?
Looking for a developper
Switching forum from subdomain to sub directory
How to install discourse with nginx as proxy on specific path?
All IPs recorded as 127.0.0.1
How to install discourse with nginx as proxy on specific path?
SetupWizard, blank screen, JS Error "`virtual-dom"
Trouble connecting drupal and discourse
Failed to Bootstrap - launcher rebuild app
Redirect from one server to another server and keep everything after the URL
Installation on v-server as a subfolder with other services in subfolders using apache

: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 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

Nothing, that should be copied as written.

That should also be copied as written

Yes, it should now be example.com

5 Mi Piace

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 Mi Piace

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 Mi Piace

La mia esperienza:

force https -\u003e checked

Ho anche dovuto eseguire il proxy di /assets a subfolder/assets altrimenti avrebbe restituito 404 per *.js.map

… e ovviamente $http_your_original_ip_header dovrebbe essere $proxy_add_x_forwarded_for per impostazione predefinita.

4 Mi Piace

Ciao,

Qualcuno ha provato a annullare la configurazione della sottocartella per un’istanza Discourse in esecuzione?

Ho configurato un’istanza per utilizzare questa configurazione, per una sottocartella come /forum, e ha funzionato. Ma alla fine, abbiamo deciso di utilizzare l’opzione del sottodominio, quindi ho provato ad annullare tutte le modifiche, ovvero rimuovere la variabile DISCOURSE_RELATIVE_URL_ROOT e la sezione run, e digitare quella predefinita:

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"

E quando l’applicazione viene ricostruita, viene visualizzata la seguente schermata quando si tenta di accedere all’URL (senza /forum):

E se provo ad andare su /forum, viene visualizzata la seguente schermata:

Quindi non so quali altre modifiche siano necessarie per farlo funzionare di nuovo.

Saluti,
Miguel.

1 Mi Piace

Quello che avrei fatto è un backup e un ripristino su un nuovo server. Questo avrebbe lasciato il tuo server esistente funzionante finché non avresti potuto testare quello nuovo. E dato che è su un nuovo sottodominio, sarebbe stato molto più facile farlo in quel modo. Ma questo non ti aiuta.

Hai fatto questo passaggio al contrario?

Penso che dovrai fare

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

ma questo non spiega l’errore “Oops”. Il posto dove guardare sono i log in

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

e

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

Ho digitato entrambi, quindi potresti dover apportare modifiche se ho sbagliato.

Felice di aiutare qui il più possibile, ma se questo conta come un’emergenza per la quale hai un budget, puoi contattarmi direttamente.

3 Mi Piace

come far funzionare i login social, intendo ora quale sarà l’URI di callback autorizzato

DISCOURSE_HOSTNAME: example.com
DISCOURSE_RELATIVE_URL_ROOT: /forum

sarà example.com o forum.example.com o example.com/forum (google e fb non accettano questo url)

1 Mi Piace

Secondo Configurazione dell’accesso a Facebook per Discourse
L’URL di callback è https://discourse.example.com/auth/facebook/callback per una sottocartella sarebbe https://discourse.example.com/forum/auth/facebook/callback

2 Mi Piace

L’app è andata bene ma poi è fallita https://example.com/community/auth/failure?message=no_authorization_code&origin=https%3A%2F%2Fexample.com%2Fcommunity%2F&strategy=facebook#_=_.

Spiacenti, si è verificato un errore durante l’autorizzazione del tuo account. Riprova.

Sono abbastanza sicuro che ciò significhi che hai la parte della sottocartella completamente corretta e ora devi sistemare la parte di Facebook, che è considerevolmente più difficile.

1 Mi Piace