Setting Charset on Nginx PHP virtual host

Francis Daly francis at
Thu Aug 1 20:07:07 UTC 2019

On Wed, Jul 31, 2019 at 05:29:37PM +0200, Vincent M. wrote:

Hi there,

> I have specified charset and overried_charset on both server and location
> and yet, it was still sending headers in UTF-8.

What does the error log say?

Is there something like

  no "charset_map" between the charsets "utf-8" and "iso-8859-1" while reading response header from upstream

there? Because that could explain why the conversion does not happen.

> On Apache we can do:
> <VirtualHost>
> ...
>     Header set Content-Type "text/html; charset=iso-8859-1"
> </VirtualHost>
> How to do the same on Nginx?

I think that that Apache config will set the Content-Type header
on responses it sends; but will not do anything to actually make the
response body be valid iso-8859-1.

The nginx "charset" module expects to modify the response body if

You can try adding a charset_map ( --
either a full one that maps between the one-byte iso-8859-1 values and
utf-8 values that differ; or just an empty one and let the &# conversion
happen instead.

  charset_map iso-8859-1 utf-8 { }

or include extra pieces like


if you want explicit conversion.

Francis Daly        francis at

More information about the nginx mailing list