All users avatars and some of images are gone after rebuilding

I just have installed discourse docker on a subdirectory of my website and I have an ubuntu server after installing I uploaded some images and avatars for users and now all avatars and some of the images are giving 404 error I have followed this documentation.

avatars are now looking like this

some of the images looking like this

Subfolder stuff can be tricky and is a bit less well-tested than a normal configuration.

How old was your site before the upgrade?

It might help to share your app.yml, especially the bits having to do with the subfolder config.

Is it all images, or some images?

just created a website for testing because I have to use this sub-folder discourse in my website that has a lot of traffic so that’s why I tested the documentation before implementing it in my website

only some images but all avatars

##   Subfolder support with Docker   https://meta.discourse.org/t/subfolder-support-with-docker/30507

## discourse-terraform Docker configuration template

##

## After making changes to this file, you MUST rebuild for any changes

## to take effect in your live Discourse instance:

##

## /var/discourse/launcher rebuild app

##

## this is the all-in-one, standalone Discourse Docker container template

# You may add rate limiting to by commenting out the ratelimited template.

# Out of the box it allows 12 reqs a second per ip, and 100 per minute per ip

# This is configurable by amending the params in this file

templates:

  - "templates/postgres.template.yml"

  - "templates/redis.template.yml"

  - "templates/web.template.yml"

  - "templates/sshd.template.yml"

## which TCP/IP ports should this container expose?

expose:

  - "1357:80" #change this port to port where you want run discourse # fwd host port 80   to container port 80 (http)

  #- "2222:22" # fwd host port 2222 to container port 22 (ssh)

params:

  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to 1/3 of the memory you wish to allocate to postgres

  ## on 1GB install set to 128MB on a 4GB instance you may raise to 1GB

  db_shared_buffers: "512MB"

  #

  ## Which Git revision should this container use? (default: tests-passed)

  #version: tests-passed

env:

  LANG: en_US.UTF-8

  ## TODO: How many concurrent web requests are supported?

  ## With 2GB we recommend 3-4 workers, with 1GB only 2

  UNICORN_WORKERS: 3

  ##

  ## TODO: List of comma delimited emails that will be made admin and developer

  ## on initial signup example 'user1@example.com, user2@example.com'

  DISCOURSE_DEVELOPER_EMAILS: "ahmeds.works@gmail.com" #change these emails to site admins emails

  ##

  ## TODO: The domain name this Discourse instance will respond to

  DISCOURSE_RELATIVE_URL_ROOT: /ask 

  DISCOURSE_HOSTNAME: "example.com"

  ##

  ## TODO: The mailserver this Discourse instance will use

  # change smtp setting to your own smtp setting

  DISCOURSE_SMTP_ADDRESS: smtp-relay.test.com

  DISCOURSE_SMTP_PORT: 587

  DISCOURSE_SMTP_USER_NAME: test@test.com

  DISCOURSE_SMTP_PASSWORD: example

##

  ## The CDN address for this Discourse instance (configured to pull)

  #DISCOURSE_CDN_URL: //discourse-cdn.example.com

## These containers are 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

## The docker manager plugin allows you to one-click upgrade Discouse

## http://discourse.example.com/admin/docker

hooks:

  after_code:

    - exec:

        cd: $home/plugins

        cmd:

          - mkdir -p plugins

          - git clone https://github.com/discourse/docker_manager.git

## Remember, this is YAML syntax - you can only have one block with a name

run:

    - exec:

        cd: $home

        cmd:

          - mkdir -p public/ask

          - cd public/ask && 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 ^/(.*)$ /ask/$1 break;

          proxy_pass http://discourse;

    - replace:

       filename: /etc/nginx/conf.d/discourse.conf

       from: etag off;

       to: |

          etag off;

          location /ask {

             rewrite ^/ask/?(.*)$ /$1;

          }

    - replace:

         filename: /etc/nginx/conf.d/discourse.conf

         from: $proxy_add_x_forwarded_for

         to: $http_fastly_client_ip

         global: true

    - exec: echo "End of custom commands"

    - exec: awk -F\# '{print $1;}' ~/.ssh/authorized_keys | awk 'BEGIN { print "Authorized SSH keys for this container:"; } NF>=2 {print $NF;}' 

here’s my Nginx config

server {

        listen 80 ;

        server_name privitevps.ga;

        

        root /var/www/html/privitevps.ga/;

        index index.html index.htm index.nginx-debian.html index.php;

        location / {

            try_files $uri $uri/ /index.php$is_args$args;

        }

            location ~ \.php$ {

        include snippets/fastcgi-php.conf;

    

        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

    }

        location /ask/ { #your sub directory where you want to run discourse 

            proxy_pass      http://localhost:1357/ask; #your local port where discourse is running in my case its running in "1357" than you subdirectory where you want to run discourse

            proxy_read_timeout      90;

            proxy_redirect  http://localhost:1357/ask https://privitevps.ga/ask; #Redirecting proxy from localhost to your domain 

        }

}

@pfaffman my test website

1 Like