How to customize MIME media type emitted for certain attachments?

I have some users that wish to attach some files with uncommon file extensions to their posts. The files are basically text files so I’d like Discourse’s NGINX web server to emit the MIME media type “text/plain” when users download these files from Discourse.

Predictably, NGINX doesn’t recognize these uncommon file extensions. As a result, it currenlty emits “application/octet-stream” for these files.

I successfully updated the NGINX config to instruct it to use “text/plain” for these extensions but it still insists on using “application/octet-stream” when the users download the files from the posts.

Here’s what I did (the file extensions in this example are “.foo” and “.bar”):

  1. sudo vi /var/discourse/containers/app.yml
    In the “run” section, just before the “End of custom commands” echo statement, added:
  - replace:
      filename: /etc/nginx/mime.types
      from: "txt;"
      to: "txt foo bar;"
  1. cd /var/discourse
  2. sudo ./launcher rebuild app

I’ve “bashed” into the container and verified the NGINX file was updated correctly from

text/plain    txt;


text/plain    txt foo bar;

What am I doing wrong?

I also tried using the “replace” mechanism to update the “types” section within /etc/nginx/conf.d/discourse.conf but that didn’t work either.

Thanks in advance!

Hi everyone…does anyone have any ideas why this isn’t working?