Discourse on subfolder with reverse proxy - images not loading

(Flaviu) #1


I have just installed Discourse on a host with reverse proxy on another host. The subfolder is www.example.com/community

Everything work as expected but the images are not showing up.

These are the relevant config values:


  DISCOURSE_HOSTNAME: 'www.example.com'


      - exec: echo "Beginning of custom commands"
      - exec:
            cd: $home
              - 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;
      - replace:
             filename: /etc/nginx/conf.d/discourse.conf
             from: $proxy_add_x_forwarded_for
             to: $http_your_original_ip_header
             global: true

      - exec: echo "End of custom commands"

all the Images instead of being img src=“community/img” they are img src=“img”

Is there a simple way to resolve this issue?

Thank you,

(Flaviu) #2

Dear @codinghorror, do you have any idea why some pictures/avatars have the correct path (appears correctly ) and some are not if I use Discourse behind a reverse proxy?

There are some pictures which are rendered as <img src="/images/lock.svg"> instead of <img src="/community/images/lock.svg"> (/community is the relative URL path , Discourse is configured with: DISCOURSE_RELATIVE_URL_ROOT: /community)

in my case I have the Discourse installed on a dedicated server with reverse proxy on another server. The path to the Discourse is example.com/community

For some of the pictures like to logo, I have been able to configure from the admin section, adding the /community in front of all the picture.

Unfortunately not all the images can be configured from the admin section and as I mention above, some of the picture don’t have the right path.

Is there any way in which I can resolve this? Is something that I am doing wrong or it may be a real bug?

As an example, please see below image

for this particular example the img url have the format <img src="/images/emoji/apple/smile.png">. The correct format should be <img src="/community/images/emoji/apple/smile.png">.

but as you can see some pictures like the Discourse logo are rendered correctly on other part of the page (bottom left).

Thank you,