amuck-landowner

Nginx, MIME types and Firefox

MannDude

Just a dude
vpsBoard Founder
Moderator
Yesterday and the day before pushed out some updates on the forum (server side for the WWW and Ad server), to speed things up a tad. This included updating Nginx  and some SSL and Gzip related tweaks.

However it's come to my attention today that the ads now display strangely in FireFox, and FireFox only. I normally use Chromium myself, but can confirm the error exists in Iceweasel/Firefox. Load the site in each browser and you'll see what I am referring to.

Someone mentioned to me the following:

This error message seems to be specific to Firebug, but is not a bug in Firefox (no other browser / plugin seems to point this out, or even recognise this as an error). I inspected a single request to vpsboard.com, and right at the end of the page load there was this invalid request:
The stylesheet https://u628b3.vpsboard.com/static/css/main.css was not loaded because its MIME type, "application/octet-stream", is not "text/css"

But I'm not quite sure how to correct this so that Firefox recognizes the file as text/css properly. It seems that the solution is server side. Nginx needs to send the correct MIME type for files with a .css extension. I am not entirely sure how to do this though. Any thoughts?
 

MannDude

Just a dude
vpsBoard Founder
Moderator
`/etc/nginx/mime.types` should have a line like "text/css css;"
It does already, but this as if it's probably due to gzip altering the MIME type and Firefox is treating it differently than Chrome. Only in Firefox does it not detect it as 'text/css'.
 

Nett

Article Submitter
Verified Provider
Gzip is probably the issue :(. Have you tried to minimise the CSS file and disable Gzip for .css?
 

MannDude

Just a dude
vpsBoard Founder
Moderator
Hmm, I removed  text/css from "gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;" in nginx.conf... restarted nginx. Didn't fix the issue. Then just disabled gzip entirely on the server and the issue persists.

Any ideas?
 

manacit

New Member
I don't think it's a gzip issue - requesting the page without an Accept: Gzip header with curl gives me the following HTTP response:

Code:
$ curl -I https://u628b3.vpsboard.com/static/css/main.css
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 31 Mar 2014 20:02:12 GMT
Content-Type: application/octet-stream
Content-Length: 426
Last-Modified: Sun, 19 Jan 2014 05:36:27 GMT
Connection: keep-alive
ETag: "52db645b-1aa"
Accept-Ranges: bytes
The application/octet-stream header tells me that nginx isn't reading your mime type file correctly. Inside nginx.conf, make sure you have a line that resembles the following:

Code:
    include       mime.types;
If you don't, it will send files as the default mime type, which is application/octet-stream. For the record, this is what mine looks like: https://gist.github.com/nickvanw/9901057
 
Last edited by a moderator:

MannDude

Just a dude
vpsBoard Founder
Moderator
I don't think it's a gzip issue - requesting the page without an Accept: Gzip header with curl gives me the following HTTP response:


$ curl -I https://u628b3.vpsboard.com/static/css/main.css
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 31 Mar 2014 20:02:12 GMT
Content-Type: application/octet-stream
Content-Length: 426
Last-Modified: Sun, 19 Jan 2014 05:36:27 GMT
Connection: keep-alive
ETag: "52db645b-1aa"
Accept-Ranges: bytes

The application/octet-stream header tells me that nginx isn't reading your mime type file correctly. Inside nginx.conf, make sure you have a line that resembles the following:

Code:
    include       mime.types;
If you don't, it will send files as the default mime type, which is application/octet-stream. For the record, this is what mine looks like: https://gist.github.com/nickvanw/9901057
Man oh man. It's alway something simple, isn't it!

nginx.conf was indeed missing 'include mime.types;'

Re-enabled gzip as well. Everything is working fine. May need to hard refresh or clear cache if using FF, but afterwards everything displays normally!
 
Top
amuck-landowner