I understand that the “charset utf-8” directive in an http or server block of a configuration file should make nginx include “Content-Type: text/html; charset=utf-8” in the headers of a response, instead of only “Content-Type: text/html”.

However, I have added that directive to both the http block and the applicable server block, and the “Content-Type” directive has remained unchanged.

Precautions taken include: 1. Reloading or restarting nginx after each config change. 2. Including a “charset_types text/html text/plain;” directive before. 3. Making an unrelated config change and verifying that it DOES have its expected effect.

I have looked at the related discussions here and at the nginx documentation and not found any explanation.

  • What nginx version? What files are you serving? What is the nginx configuration? Commented Feb 24, 2018 at 0:10

2 Answers 2


charset utf-8;

in your server{} block should be all you need to do. Based on the nginx documentation here


you can place this in http, server, or location contexts.


Thank you for the replies. I finally realized that I was looking at the headers of a 301 response. URLs without a trailing slash are redirected to the same URLs with a trailing slash. The 301 response has “text/html” as its content type. But the following response after the redirect has “text/html; charset=utf-8” as its content type. I don’t know how useful it is for the 301 response to have the charset parameter declared, but, since it does declare text/html as the content type, if the nginx config sets charset in the http block, should we not expect charset in the 301 response, too? The nginx version is 1.10.3 (Ubuntu).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .