I have difficulties to apply this if statement in my nginx config:
location / {
break;
proxy_pass http://127.0.0.1:4444;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if ($arg_charset ~* windows-1251) {
charset windows-1251;
}
source_charset utf-8;
}
I have tried $arg_charset ~* “windows-1251” and $arg_charset ~* /.windows-1251./ and all others solutions. None does work…
Removing if statements give me wanted results, so the problem is inside if statement condition.
It’s a bug or i’m doing it wrong?
As http://wiki.nginx.org/IfIsEvil explains,
ifblocks inside alocationare known to be potentially problematic when they contain anything other then areturnorrewritetry simply moving the if into the
serverblock directly (whereifhas no problems) that should fix it.updated to avoid using
charsetdirective in serverblock:try something like the following:
NOTE: make sure you have the win-utf
charset_mapincluded in your http block (on my debian system that meansinclude /etc/nginx/win-utf;)