Catalogue
Investigating the Nginx Error "duplicate MIME type 'text/html' in /etc/nginx/nginx.conf"

Investigating the Nginx Error "duplicate MIME type 'text/html' in /etc/nginx/nginx.conf"

🌐 日本語で読む

Overview

Having error logs sent to Slack as notifications is really convenient.

Once in a while, though, something shows up that makes you go “what is this?”

One of those is the error in the title.

1
duplicate MIME type "text/html" in /etc/nginx/nginx.conf

Looking at nginx.conf, it was the text/html that I had set in gzip_types.

Translated literally, it says:

1
The MIME type "text/html" is duplicated in /etc/nginx/nginx.conf.

So I figured I could just remove it, and removing it solved the problem.

/etc/nginx/nginx.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
gzip              on;
gzip_static on;
gzip_http_version 1.0;
gzip_types text/plain
text/html
text/xml
text/css
application/xml
application/xhtml+xml
application/rss+xml
application/atom_xml
application/javascript
application/x-javascript;
gzip_disable "MSIE [1-11]\.(?!.*SV1)";
gzip_disable "Mozilla/4";
gzip_comp_level 9;
gzip_vary on;

Is it specified somewhere else?

To get to the point:

  • if you have ngx_http_gzip_module installed
  • and you set gzip on

then text/html is specified as a MIME type by default.

You can confirm this by checking the official site below.

gzip_types

It says that the text/html type is always subject to compression.

So when you do gzip compression, text/html is unnecessary.

And that was the answer.

kenzo0107

kenzo0107