Setting Charset on Nginx PHP virtual host

Francis Daly francis at
Sun Aug 4 21:57:15 UTC 2019

On Sun, Aug 04, 2019 at 03:11:36PM +0200, Vincent M. wrote:

Hi there,

> But the special characters was displayed with "?" not with � .

I wonder...

The nginx docs say """Missing characters in the range 80-FF are replaced
with “?”. """

Is there any chance that the response body is actually iso-8859-1,
but the header claims that it is utf-8? In that case, you would want to
change the header, but *not* convert the body.

(Strictly: you would want to fix the source, so that it does not lie
about its content. But if you can't do that, then "just" changing the
header in nginx may be adequate.)

> Anyway, it's a PHP issue not Nginx. The default PHP charset config is set to
> "utf-8" and to overwrite it, I have added on the beginning of my script:
>     ini_set('default_charset', 'iso-8859-1');
> And it's working fine...

Great that you have an overall configuration that works for you.


Francis Daly        francis at

More information about the nginx mailing list