Discourse Multisite – Nginx (Inside Docker) Only Serving Default Site

AI-generated summary

The user Abdelrahman_MoHamed is facing issues with Discourse multisite setup using Docker, where Nginx inside the container only serves the default site and additional sites fail to load. Despite following the official documentation and configuring multisite.yml with multiple sites (e.g., forum.getweldingjobs.com, forum.medicaltranscriptionjobs.com), the setup does not work as expected. The user notes that disabling Let’s Encrypt and enabling Cloudflare proxy causes all sites to become inaccessible. The app.yml configuration includes the necessary templates, ports, environment variables, and database settings, but the multisite functionality remains broken. pfaffman suggests the issue might be related to Cloudflare settings or incorrect host names.

Hi everyone,

I’m setting up Discourse multisite using discourse_docker, but I’m facing issues with Nginx inside the container. I’ve followed the official documentation, but I can’t get all sites to work correctly.

Findings So Far:

  • The Nginx inside the Discourse Docker image is only serving the default site – additional sites don’t load.
I, [2025-03-19T03:38:06.444387 #1]  INFO -- : Replacing (?-mix:server.+{) with server {
  listen 80;
  return 301 https://$$ENV_DISCOURSE_HOSTNAME$request_uri;
}
  • When I disable Let’s Encrypt and enable Cloudflare proxy, all sites become inaccessible.
  • I’ve checked the app.yml multisite configuration and rebuilt the container, but the issue persists.

Here is the current config

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.ssl.template.yml"

expose:
  - "80:80"
  - "443:443"

params:
  db_default_text_search_config: "pg_catalog.english"
  db_shared_buffers: "256MB"

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  UNICORN_WORKERS: 4
  DISCOURSE_MAX_ADMIN_API_REQS_PER_KEY_PER_MINUTE: 5000
  DISCOURSE_MAX_REQS_PER_IP_PER_MINUTE: 5000
  DISCOURSE_HOSTNAME: forum.getnursingjobs.com
  DISCOURSE_DB_USERNAME: discourse
  DISCOURSE_DB_PASSWORD: "REPLACE_WITH_ENV_VAR"
  DISCOURSE_DB_HOST: DB IP
  DISCOURSE_DB_NAME: 
  DOCKER_USE_HOSTNAME: true
  DISCOURSE_DEVELOPER_EMAILS: 
  DISCOURSE_SMTP_ADDRESS: 
  DISCOURSE_SMTP_PORT: 
  DISCOURSE_SMTP_USER_NAME: 
  DISCOURSE_SMTP_PASSWORD: "REPLACE_WITH_ENV_VAR"
  DISCOURSE_NOTIFICATION_EMAIL: 
  DISCOURSE_REPLY_BY_EMAIL_ADDRESS: 
  DISCOURSE_MAXMIND_ACCOUNT_ID: 
  DISCOURSE_MAXMIND_LICENSE_KEY: "REPLACE_WITH_ENV_VAR"
  DISCOURSE_EMAIL_SITE_TITLE: 'GetNursingJobs.com'

volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

hooks:
  after_postgres:
    - exec: sudo -u postgres createdb b_discourse || exit 0
    - exec:
        stdin: |
          grant all privileges on database b_discourse to discourse;
        cmd: sudo -u postgres psql b_discourse
        raise_on_fail: false
    - exec: /bin/bash -c 'sudo -u postgres psql b_discourse <<< "alter schema public owner to discourse;"'
    - exec: /bin/bash -c 'sudo -u postgres psql b_discourse <<< "create extension if not exists hstore;"'
    - exec: /bin/bash -c 'sudo -u postgres psql b_discourse <<< "create extension if not exists pg_trgm;"'

  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-adplugin.git
          - git clone https://github.com/discourse/discourse-google-one-tap.git

  before_bundle_exec:
    - file:
        path: $home/config/multisite.yml
        contents: |
          welding:
            adapter: postgresql
            database: discourse_welding
            username: discourse
            password: "REPLACE_WITH_ENV_VAR"
            host: DB IP
            pool: 25
            timeout: 5000
            db_id: 2
            host_names:
              - forum.getweldingjobs.com
          medical:
            adapter: postgresql
            database: discourse_medical
            username: discourse
            password: "REPLACE_WITH_ENV_VAR"
            host: DB IP
            pool: 25
            timeout: 5000
            db_id: 3
            host_names:
              - forum.medicaltranscriptionjobs.com
          dataentry:
            adapter: postgresql
            database: discourse_dataentry
            username: discourse
            password: "REPLACE_WITH_ENV_VAR"
            host: DB IP
            pool: 25
            timeout: 5000
            db_id: 4
            host_names:
              - forum.dataentryjobs.com
          chef:
            adapter: postgresql
            database: discourse_chef
            username: discourse
            password: "REPLACE_WITH_ENV_VAR"
            host: DB IP
            pool: 25
            timeout: 5000
            db_id: 5
            host_names:
              - forum.getchefjobs.com

  after_bundle_exec:
    - exec: cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate

What I Need Help With:

  1. How can I configure the internal Nginx inside the container to serve all multisite domains?
  2. Are there specific app.yml settings I need to adjust for this setup?

I believe the problems were having the orange cloud and using the wrong host names.