1

So I have a RatticDB installation setup (Django App) on Port 8000 and in front of that I have Nginx on port 80. It is currently serving svg files as application/octet-stream which is causing the svg file to be downloaded vs served.

rattic.conf:

upstream django {
    server      127.0.0.1:8000;
}

server {
    listen          80;
    server_name         locksmith.internal.domain.com;
    charset         utf-8;
    client_max_body_size    75M;

    location /raddicweb/static {
    alias       /home/locksmith/RatticWeb/ratticweb/static;
    }

    location /cred/static {
    alias       /home/locksmith/RatticWeb/cred/static;
    }

    location / {
    uwsgi_pass  django;
    include     /etc/nginx/uwsgi_params;
    }

    types {
    image/svg+xml   svg svgz;
    }

  }

Now the nginx.conf includes mime types and mime types has this set, where do I go from here? [root@ip ~]# grep -R mime.types /etc/nginx/ /etc/nginx/nginx.conf: include /etc/nginx/mime.types; [root@ip ~]# grep svg /etc/nginx/mime.types image/svg+xml svg svgz;

morissette
  • 1,071
  • 1
  • 8
  • 29
  • Possible duplicate of [Can the Django dev server correctly serve SVG?](https://stackoverflow.com/questions/2312714/can-the-django-dev-server-correctly-serve-svg) – bubbassauro Feb 23 '18 at 21:19

1 Answers1

0

Apparently, Django needs to serve these as well as nginx; so the problem was at the Django level and solved by adding the following to settings.py and restarting uwsgi:

import mimetypes

mimetypes.add_type("image/svg+xml", ".svg", True)
mimetypes.add_type("image/svg+xml", ".svgz", True)
morissette
  • 1,071
  • 1
  • 8
  • 29