No subfolder prefixing for some resources

Version: v2.6.0.beta2
Setup: Subfolder /forum/discourse setup running on Docker w/ Apache reverse proxy on host /forum/discourse

I have followed the instructions here for the subfolder setup and the installation works fine.

However, some resource URLs are not correctly prefixed and lead to 404s. For example, the URL for the default header logo should be /forum/discourse/images/discourse-logo-sketch.png but Discourse uses /images/discourse-logo-sketch.png.

I’m not quite familiar with the codebase but I think that this should be solved by wrapping application_logo_url with UrlHelper.absolute() here.

I will add to the topic if I find any other instances of the problem. Let me know if this is indeed an issue or if I’m doing something wrong. I’d be more than happy to submit a PR.

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

expose:
# host has a reverse proxy on these ports
  - "8080:80"   # http
  - "8443:443" # https

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

env:
  LANG: en_US.UTF-8
  UNICORN_WORKERS: 8
  DISCOURSE_HOSTNAME: mydomain.com
  DISCOURSE_RELATIVE_URL_ROOT: /forum/discourse
  DISCOURSE_DEVELOPER_EMAILS: 'info@mydomain.com'
  DISCOURSE_SMTP_ADDRESS: mydomain.com
  DISCOURSE_SMTP_PORT: 25
  DISCOURSE_SMTP_USER_NAME: user
  DISCOURSE_SMTP_PASSWORD: pass

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
## https://meta.discourse.org/t/subfolder-support-with-docker/30507
  - exec:
      cd: $home
      cmd:
        - mkdir -p public/forum/discourse
        - cd public/forum/discourse && ln -s ../../uploads && ln -s ../../backups
  - replace:
      global: true
      filename: /etc/nginx/conf.d/discourse.conf
      from: proxy_pass http://discourse;
      to: |
          rewrite ^/(.*)$ /forum/discourse/$1 break;
          proxy_pass http://discourse;
  - replace:
      filename: /etc/nginx/conf.d/discourse.conf
      from: etag off;
      to: |
          etag off;
          location /forum/discourse {
              rewrite ^/forum/discourse/?(.*)$ /$1;
          }
  - replace:
      global: true
      filename: /etc/nginx/conf.d/discourse.conf
      from: $proxy_add_x_forwarded_for
      to: $http_your_original_ip_header
  - exec: echo "End of custom commands"

The placeholders resources don’t load the subfolder path indeed, but as soon as you finish the wizard setup the new logs added with it will have the subfolder prefix.

5 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.