
我已經在 CentOS 6.4 機器上使用 mod_proxy、mod_proxy_html (3.1.3) 和 mod_xml2enc 設定了反向代理。
代理可以很好地為目標伺服器提供服務,但它會混淆非 ASCII 字元(在我的例子中為“äöüéàè”)。
我用谷歌搜尋了整個地圖,試圖找到解決方案,但無濟於事。
在回應標頭中正確指定了編碼,並且與目標伺服器的編碼 (utf-8) 相同。我還嘗試透過以下方式明確設定 xml2enc 使用的編碼:
xml2EncDefault utf-8
但沒有效果。
我正在虛擬主機上運行代理,代理配置設定如下:
ProxyRequests off
ProxyHTMLLinks a href
ProxyHTMLLinks area href
ProxyHTMLLinks link href
ProxyHTMLLinks img src longdesc usemap
ProxyHTMLLinks object classid codebase data usemap
ProxyHTMLLinks q cite
ProxyHTMLLinks blockquote cite
ProxyHTMLLinks ins cite
ProxyHTMLLinks del cite
ProxyHTMLLinks form action
ProxyHTMLLinks input src usemap
ProxyHTMLLinks head profile
ProxyHTMLLinks base href
ProxyHTMLLinks script src for
ProxyHTMLLinks iframe src
ProxyPass /foo/ http://someserver.com/
ProxyPassReverse /foo/ http://www.someserver.com/
<Location /foo/>
SetOutputFilter INFLATE;proxy-html;DEFLATE
ProxyPassReverse /
ProxyPassReverseCookiePath / /foo
ProxyHTMLURLMap http://www.someserver.com /foo
ProxyHTMLURLMap http://someserver.com /foo
RequestHeader unset Accept-Encoding
</Location>
答案1
事實證明「mod_proxy_html」在這一切中是無辜的。
透過以下方式聲明編碼:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
讓這個問題消失了。
這有點奇怪,因為“Content-Type”已在回應標頭中正確設定。