Blank Page After installing Discourse on Subfolder

Hey!

I am trying to setup discourse on a subfolder. Followed the how-to but I get a blank page with 404 on all resources.

I entered the container app and tried the following command but get an error:

root@discourse:/var/www/discourse# RAILS_ENV=production bundle exec script/discourse remap '/uploads' '/community/uploads'
bundler: failed to load command: script/discourse (script/discourse)
PG::ConnectionBad: FATAL:  Peer authentication failed for user "discourse"

Also my server’s nginx conf:

 location /community/ {
#                rewrite         /(.*) /$1  break;
                proxy_pass      http://meta.domain.org:25654/;
                proxy_read_timeout      90;
                proxy_redirect  http://meta.domain.org:25654/ https://meta.domain.org/;
                proxy_set_header Host $http_host;
                proxy_http_version 1.1;
#               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

YAML Config:

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

That’s the problem you need to look at first. Did the site work without subfolder?

4 Likes

@neil Yes, the site was working fine on the subdomain. But, after bootstrapping its unable to find resources i.e. it’s looking for assets/stylesheets and other resources in sub.domain.org/* instead of sub.domain.org/community. but, uploads files are fine with path sub.domain.org/community/uploads/.

Is it because of the previous database? as that was on the subdomain.

Also, I am not sure if community should exist in the public as in logs it shows:

I, [2018-08-31T20:27:08.692777 #14]  INFO -- : > cd /var/www/discourse && mkdir -p public/community
I, [2018-08-31T20:27:08.696953 #14]  INFO -- :
I, [2018-08-31T20:27:08.697067 #14]  INFO -- : > cd /var/www/discourse && cd public/community && ln -s ../uploads && ln -s ../backups 
....

but then in the container:

[root@server discourse]# sudo ./launcher enter app
which: no docker.io in (/sbin:/bin:/usr/sbin:/usr/bin)
root@discourse:/var/www/discourse# cd  public/community
bash: cd: public/community: No such file or directory

The database should not have changed just because you added configuration for subfolder. Also, even though you can see that public/community is being created, it doesn’t exist. This is very confusing. I can’t tell what’s wrong with your setup so I don’t know how to help.

Hmm but uploads folder is working fine, the images that I uploaded previously exist in the subfolder.

It’s something like below:

This is fine.
<link rel="icon" type="image/png" href="/community/uploads/default/original/1X/87da3cc4e563ce7b15dc0b01e79d04714.ico">

This is wrong. Should have been /community/assets...

<script src='/assets/locales/en-ef130f04fe2d3ddf9d0b85d2da12e75a5b16387aa046890bcaf41c2a.js'></script>
<link href="/stylesheets/desktop_theme_3_6a8144912cf399034c2b503bd01fc6bcdd.css?__ws=meta.domain.org" media="all" rel="stylesheet" data-target="desktop_theme"/>

This should have been /community/t.....

  <a href='/t/welcome-to-community-read-first/8' itemprop='item'>

Here’s some other yml I’ve used. Yours is missing the assets precompile:

  - exec:
      cd: $home
      cmd:
        - rm -fr public/assets
        - sudo -E -u discourse bundle exec rake assets:precompile
        - mkdir -p public/community
        - cd public/community && ln -s ../uploads && ln -s ../backups
  - replace:
     global: true
     filename: /etc/nginx/conf.d/discourse.conf
     from: proxy_pass http://discourse;
     to: |
        rewrite ^/(.*)$ /community/$1 break;
        proxy_pass http://discourse;
  - replace:
     filename: /etc/nginx/conf.d/discourse.conf
     from: etag off;
     to: |
        etag off;
        location /community {
           rewrite ^/community/?(.*)$ /$1;
        }
2 Likes

Now my config:

run:
    - exec:
        cd: $home
        cmd:
          - rm -fr public/assets
          - sudo -E -u discourse bundle exec rake assets:precompile
          - mkdir -p public/community
          - cd public/community && ln -s ../uploads && ln -s ../backups
          - rm public/uploads
          - rm public/backups
    - replace:               
    .....

gives me /community/community/uploads rather than /community/uploads/. But assets/stylesheets remain the same as before i.e. instead of being located in the community folder, the site is searching these files in sub.domain.org.

I can’t tell what the cause of all your problems (can’t connect to db, multiple /community directories, wrong assets path, etc…) is from this topic. and I’ve never seen those problems from a subfolder config before. I recommend going back to subdomain.

3 Likes

Strange but it worked by destroying all containers and then rebuilding from scratch.

sudo ./launcher destroy app
docker rmi .....
sudo ./launcher rebuild app

3 Likes

This topic was automatically closed after 44 hours. New replies are no longer allowed.