How to overwrite default Content-Type in nginx? Currently when I request 01.dae file, there's
Content-Type: application/octet-stream;
And I want it to be
Content-Type: application/xml;
I tried something like
location ~* \.dae$ { types { }; default_type application/xml; }
and
location ~* \.dae$ { add_header Content-Type application/xml; }
but nothing works.
It is determined by the name of the file actually returned. The try_files statement in your last configuration will return the requested file if it exists, otherwise index. html is returned, and that file has a MIME type of text/html .
The default mime. types file from nginx only contains MIME types for more or less common file extensions. And it certainly isn't very common to have json static files. Also, what types should be gzipped? You may include MIME types for all well compressible content that you have on your site.
In case you have no file extension:
location ~ something { default_type application/xml; }
Nginx docs for default_type
In case you are setting up let's encrypt certificate with a client which creates http server: How to use golang lego let's encrypt client behind nginx?
You can edit /etc/nginx/mime.types
and add it
types { application/xml dae; }
I haven't found the the exact string application/xml
in my mime.types
so I suppose you can directly include it inside your server block, in the server scope or something.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With