问题
I have a problem ultimately caused by a third party XML document whose actual encoding (ISO 8859-1 or Windows 1252, can't tell) doesn't match its declared encoding (UTF-8).
I'm looking for creative workarounds. We already use nginx proxies for various content, so perhaps there is a way to either:
- Re-encode the document contents on the fly from ISO 8859-1 to UTF-8; or
- Alter the document header on the fly, from UTF-8 to ISO 8859-1.
Are either of these possible with nginx? If not, a similar tool?
回答1:
Short answer, yes it can.
include win-utf;
server {
listen 5080;
location /... {
proxy_pass https://mapsengine.google.com;
source_charset windows-1251;
charset utf-8;
}
}
That is:
source_charset
specifies what you're converting fromcharset
specifies what you're converting to- and
include win-utf
brings in a file with acharset_map
which does the conversion.
Only conversions between Windows 1251, UTF-8 and KOI8-R are supported out of the box.
More info: http://nginx.org/en/docs/http/ngx_http_charset_module.html
来源:https://stackoverflow.com/questions/29958824/can-nginx-re-encode-xml-documents-or-alter-xml-headers