Nginx how to serve text files with a “Content-Type: text/plain; charset=UTF-8” header?

How can I serve text (.txt) files with header Content-Type: text/plain; Charset=UTF-8 in Nginx?

I have a nginx/1.18.0 running on Ubuntu 20.04, and in nginx.conf I have this set:

http {
(...)
        include /etc/nginx/mime.types;

And in mime.types I have this:

types {
(...)
    text/plain                            txt;

But when I access text files, it’s served with these headers:

HTTP/1.1 200 OK
(...)
Content-Type: text/plain

But I want to serve it with these headers:

Content-Type: text/plain; charset=UTF-8

How can I do that?

Read more here: Source link