# Avatar uploads broken on subfolder installs?

**URL:** https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643
**Category:** Bug
**Created:** [October 26, 2018, 6:14pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643 "2018-10-26T18:14:35Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Jokestress](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jokestress/32/123467_2.png) [@Jokestress](https://meta.discourse.org/u/Jokestress)
#### Post date: [October 26, 2018, 6:14pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/1 "2018-10-26T18:14:35Z")

</div>

I’m having the same issue on a newly-installed forum running the latest and greatest version. The progress bar gets to the end of the upload then shows this message:

 ![avatarissue](https://global.discourse-cdn.com/meta/original/3X/f/0/f0d5fe2a0696d3d6634359615e305ef6c6ff75d4.jpeg)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2018, 12:17am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/2 "2018-10-27T00:17:53Z")

</div>

What file format is the image? Is it mislabled as a JPG when it is actually something weirder like a BMP? I’ve seen this happen for image files that were the wrong type.

---

<div class="post-metadata">

### Author: ![orenwolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/orenwolf/32/119529_2.png) [@orenwolf](https://meta.discourse.org/u/orenwolf)
#### Post date: [October 27, 2018, 12:21am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/3 "2018-10-27T00:21:19Z")

</div>

I was able to test this using the Boing Boing hosted Discourse instance.

The avatar image will work there, However, the same image will not work on the [hairtell.com/forum](http://hairtell.com/forum) instance (running v2.2.0.beta3 +123).

Other asset uploads work fine, and no SSO overrides are enabled (nor anything fun like S3).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2018, 12:26am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/4 "2018-10-27T00:26:56Z")

</div>

Does it work on [try.discourse.org](http://try.discourse.org)?

It never hurts to upgrade to latest, and there have been some docker image updates so I’d do that using the standard command line 3-liner as well.

---

<div class="post-metadata">

### Author: ![orenwolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/orenwolf/32/119529_2.png) [@orenwolf](https://meta.discourse.org/u/orenwolf)
#### Post date: [October 27, 2018, 1:23am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/5 "2018-10-27T01:23:07Z")

</div>

> [@Problems with avatar uploads due to S3 changes](https://meta.discourse.org/t/problems-with-avatar-uploads-due-to-s3-changes/99400/27):
>
> Does it work on [try.discourse.org](http://try.discourse.org)?

Yep.

> [@Problems with avatar uploads due to S3 changes](https://meta.discourse.org/t/problems-with-avatar-uploads-due-to-s3-changes/99400/27):
>
> It never hurts to upgrade to latest, and there have been some docker image updates so I’d do that using the standard command line 3-liner as well.

Yep, v2.2.0.beta3 +123 is latest. I rebuilt the container just-in-case. Same issue. I’m going to bet it’s a subdirectory issue specifically since that’s probably the only significant difference. I’d claim local install config issue except uploading images works without issue (that and I’ve followed the official subdomain install instructions as well, vetted by @pfaffman no less).

BTW, when looking for this infamous Discourse 3-liner, I wasn’t able to find it in the [Install guides](https://github.com/discourse/discourse/blob/master/docs/INSTALL.md), and most of the references to on google were actually references to @codinghorror asking people to use it (rather than defining what it is), so for anyone googling:

When @codinghorror refers to the “standard command 3-liner”, _to the best of my knowledge_, he means:

```
cd /var discourse
git pull
./launcher rebuild app

```

(or the name of your container config)

Thanks.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2018, 1:29am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/6 "2018-10-27T01:29:31Z")

</div>

> [@Problems with avatar uploads due to S3 changes](https://meta.discourse.org/t/problems-with-avatar-uploads-due-to-s3-changes/99400/28):
>
> Yep, v2.2.0.beta3 +123 is latest

Errr, no it isn’t. 2.2.0 beta3 +148 is latest at the moment.

---

<div class="post-metadata">

### Author: ![orenwolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/orenwolf/32/119529_2.png) [@orenwolf](https://meta.discourse.org/u/orenwolf)
#### Post date: [October 27, 2018, 1:46am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/7 "2018-10-27T01:46:04Z")

</div>

Indeed. Updated to latest, same issue.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2018, 2:25am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/8 "2018-10-27T02:25:28Z")

</div>

> [@Problems with avatar uploads due to S3 changes](https://meta.discourse.org/t/problems-with-avatar-uploads-due-to-s3-changes/99400/28):
>
> I’m going to bet it’s a subdirectory issue specifically

We should ask @neil – is there anything in this Digital Ocean install that could have been forgotten that would make this fail to work?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2018, 3:57am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/9 "2018-10-27T03:57:09Z")

</div>

Are you using amazon s3? There have been many changes in this area from @gerhard lately.

---

<div class="post-metadata">

### Author: ![orenwolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/orenwolf/32/119529_2.png) [@orenwolf](https://meta.discourse.org/u/orenwolf)
#### Post date: [October 27, 2018, 6:24am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/10 "2018-10-27T06:24:46Z")

</div>

It’s an AWS install. ELB Fronted. No S3. As I said, image uploads and asset uploads via the setup wizard work fine.

Sadly, no error logs for the upload attempts. I’ll dig at system logs tomorrow to see if there’s anything in the web logs.

---

<div class="post-metadata">

### Author: ![Jokestress](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jokestress/32/123467_2.png) [@Jokestress](https://meta.discourse.org/u/Jokestress)
#### Post date: [October 27, 2018, 4:05pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/11 "2018-10-27T16:05:35Z")

</div>

This is the picture I am trying to upload:

 ![ajj-profile-sq](https://global.discourse-cdn.com/meta/original/3X/5/6/5644d5387b88bf032d935deefd7dda6fd2a2fc8f.jpeg)

I believe it’s a run of the mill jpg with the .jpeg extension. It loads fine into posts, just not as an avatar.

Same thing happens when I convert it to .png. The upload gets to 100% then gives the error message previously posted.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 27, 2018, 5:20pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/12 "2018-10-27T17:20:22Z")

</div>

Can you make it your avatar here?

---

<div class="post-metadata">

### Author: ![orenwolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/orenwolf/32/119529_2.png) [@orenwolf](https://meta.discourse.org/u/orenwolf)
#### Post date: [October 27, 2018, 5:48pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/13 "2018-10-27T17:48:14Z")

</div>

Smoking gun!

Found a reference in the weblogs to `POST /uploads.json`. Since this is a subdomain install, it should be `/forum/uploads.json`.

For reference, here are the **existing** app.yml changes that may be relevant, and are based off of posts here for [ip headers](https://meta.discourse.org/t/last-ip-address-and-action-dispatch-trusted-proxies/50098/3) and [Docker Subfolder support](https://meta.discourse.org/t/subfolder-support-with-docker/30507):

```plaintext
DISCOURSE_RELATIVE_URL_ROOT: /forum

```

(`<ip>` replaced below)

```nginx
  after_bundle_exec:
    # This is the magic to get IP numbers transmitted to Discourse
    - replace:
        filename: /etc/nginx/conf.d/discourse.conf
        from: "types {"
        to: |
          set_real_ip_from <ip>;
          set_real_ip_from <ip>;
          real_ip_header X-Forwarded-For;
          real_ip_recursive on;
          types {

```

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

```

My guess is that the specific avatar upload isn’t honouring `DISCOURSE_RELATIVE_URL_ROOT`.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2018, 6:35pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/14 "2018-10-27T18:35:08Z")

</div>

> [@Problems with avatar uploads due to S3 changes](https://meta.discourse.org/t/problems-with-avatar-uploads-due-to-s3-changes/99400/38):
>
> `DISCOURSE_RELATIVE_URL_ROOT: /forum`

I’m unclear.. this was _not_ already set in your app.yml? If so that’s a broken install.

---

<div class="post-metadata">

### Author: ![Jokestress](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jokestress/32/123467_2.png) [@Jokestress](https://meta.discourse.org/u/Jokestress)
#### Post date: [October 27, 2018, 6:38pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/15 "2018-10-27T18:38:32Z")

</div>

Yes! I uploaded the png. I then successfully changed it out for the jpg next.

---

<div class="post-metadata">

### Author: ![orenwolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/orenwolf/32/119529_2.png) [@orenwolf](https://meta.discourse.org/u/orenwolf)
#### Post date: [October 27, 2018, 6:47pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/16 "2018-10-27T18:47:43Z")

</div>

> [@Problems with avatar uploads due to S3 changes](https://meta.discourse.org/t/problems-with-avatar-uploads-due-to-s3-changes/99400/39):
>
> I’m unclear… this was _not_ already set in your app.yml? If so that’s a broken install.

I’ve listed the app.yml changes _that already exist_ for reference above, since it is difficult to troubleshoot the install without knowing how the install differs from a base install.

With the _listed changes_ **already** in the app.yml, the avatar upload attempts a `POST` to `/uploads.json`, instead of `/forum/uploads.json`. This is not the expected result, because `DISCOURSE_RELATIVE_URL_ROOT` is set to `/forum`.

Is that more clear?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 30, 2018, 6:50am UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/18 "2018-10-30T06:50:43Z")

</div>

I have not had a chance to look at this @gerhard can you look at this first thing today.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [October 30, 2018, 12:30pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/20 "2018-10-30T12:30:46Z")

</div>

Uploads were broken for subfolder installs.  
I fixed it in [FIX: Uploads didn't work for subfolder anymore · discourse/discourse@733b8af · GitHub](https://github.com/discourse/discourse/commit/733b8af47b71f2d002d2c72105bb0ff69a153104)

---

<div class="post-metadata">

### Author: ![orenwolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/orenwolf/32/119529_2.png) [@orenwolf](https://meta.discourse.org/u/orenwolf)
#### Post date: [October 30, 2018, 5:30pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/21 "2018-10-30T17:30:04Z")

</div>

Confirmed as working now, thanks!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 30, 2018, 9:12pm UTC](https://meta.discourse.org/t/avatar-uploads-broken-on-subfolder-installs/100643/22 "2018-10-30T21:12:40Z")

</div>


