<br><font size=2 face="sans-serif">Hi, all!</font>
<br><font size=2 face="sans-serif">I have some files with un-ascii name,
and I want to use X-Accel-Redirect to control the download access. This
is my nginx-conf:</font>
<br>
<br><font size=2 face="sans-serif">server {</font>
<br><font size=2 face="sans-serif">&nbsp; listen &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;80; </font>
<br><font size=2 face="sans-serif">&nbsp; server_name &nbsp; &nbsp; update.grandes.com.cn;</font>
<br><font size=2 face="sans-serif">&nbsp; access_log &nbsp;logs/grandes_access.log
&nbsp;main;</font>
<br><font size=2 face="sans-serif">&nbsp; location /update/download {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; rewrite ^/update/download/(.+)$
/update/download.action?path=$1 last;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_pass &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;http://localhost:8080;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_redirect off;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_set_header &nbsp;
&nbsp; &nbsp; &nbsp;X-Real-IP $remote_addr;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_set_header &nbsp;
&nbsp; &nbsp; &nbsp;Host $http_host;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; client_max_body_size 10240m;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; client_body_buffer_size
128k;</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_connect_timeout
90;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_send_timeout 90;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_read_timeout 90;</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_buffer_size 4k;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_buffers 4 32k;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_busy_buffers_size
64k;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_temp_file_write_size
64k;</font>
<br><font size=2 face="sans-serif">&nbsp; }</font>
<br><font size=2 face="sans-serif">&nbsp; location /data/ {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; root /usr/local;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; internal;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; proxy_hide_header X-Accel-Redirect;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; add_header ETag $upstream_http_etag;</font>
<br><font size=2 face="sans-serif">&nbsp; }</font>
<br><font size=2 face="sans-serif">}</font>
<br>
<br><font size=2 face="sans-serif">And this's the code of '/update/download.action'
running in tomcat server, </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; public
String file() {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; response.setHeader(&quot;X-Accel-Charset&quot;,
&quot;utf-8&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; response.setHeader(&quot;X-Accel-Redirect&quot;,
path);</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; return NONE;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><font size=2 face="sans-serif">When access the path 'http://update.grandes.com.cn/update/download/WH2HOSIPTV/%E6%97%A5%E5%BF%97.txt',
nginx server report 500 Internal Server Error. Then I see the log, the
tomcat server print the path parameter like this 'WH2HOSIPTV/ÈÕÖ¾.txt'
which is right,</font>
<br><font size=2 face="sans-serif">but the nginx log track like this;</font>
<br><font size=2 face="sans-serif">2011/04/07 18:12:56 [crit] 2056#5500:
*1 CreateFile() &quot;/usr/local/data/WH2HOSIPTV/å×.txt&quot; failed (1113:
No mapping for the Unicode character exists in the target multi-byte code
page), client: 127.0.0.1, server: update.grandes.com.cn, request: &quot;GET
/update/download/WH2HOSIPTV/%E6%97%A5%E5%BF%97.txt HTTP/1.1&quot;, upstream:
&quot;http://127.0.0.1:8080/update/download.action?path=WH2HOSIPTV/%e6%97%a5%e5%bf%97.txt&quot;,
host: &quot;update.grandes.com.cn&quot;.</font>
<br>
<br><font size=2 face="sans-serif">I try to run nginx and tomcat server
both in Red Hat Enterprise Linux AS release 4 with environment variables
LANG=zh_CN.UTF-8 and windows xp which charset is GBK, and try to change
X-Accel-Charset to 'GBK', the nginx always report 500 error. The problem
existes both in nginx-0.8.54 and nginx-0.9.6. But when I change the code
in '/update/download.action' like this, it works fine! Is this a bug of
nginx?</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; public
String file() {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; response.setHeader(&quot;X-Accel-Charset&quot;,
&quot;utf-8&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; response.setHeader(&quot;X-Accel-Redirect&quot;,
new String(path.getBytes(&quot;utf-8&quot;), &quot;iso-8859-1&quot;));</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; return NONE;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">Best regards</font>