<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"> listen
80; </font>
<br><font size=2 face="sans-serif"> server_name update.grandes.com.cn;</font>
<br><font size=2 face="sans-serif"> access_log logs/grandes_access.log
main;</font>
<br><font size=2 face="sans-serif"> location /update/download {</font>
<br><font size=2 face="sans-serif"> rewrite ^/update/download/(.+)$
/update/download.action?path=$1 last;</font>
<br><font size=2 face="sans-serif"> proxy_pass
http://localhost:8080;</font>
<br><font size=2 face="sans-serif"> proxy_redirect off;</font>
<br><font size=2 face="sans-serif"> proxy_set_header
X-Real-IP $remote_addr;</font>
<br><font size=2 face="sans-serif"> proxy_set_header
Host $http_host;</font>
<br><font size=2 face="sans-serif"> client_max_body_size 10240m;</font>
<br><font size=2 face="sans-serif"> client_body_buffer_size
128k;</font>
<br>
<br><font size=2 face="sans-serif"> proxy_connect_timeout
90;</font>
<br><font size=2 face="sans-serif"> proxy_send_timeout 90;</font>
<br><font size=2 face="sans-serif"> proxy_read_timeout 90;</font>
<br>
<br><font size=2 face="sans-serif"> proxy_buffer_size 4k;</font>
<br><font size=2 face="sans-serif"> proxy_buffers 4 32k;</font>
<br><font size=2 face="sans-serif"> proxy_busy_buffers_size
64k;</font>
<br><font size=2 face="sans-serif"> proxy_temp_file_write_size
64k;</font>
<br><font size=2 face="sans-serif"> }</font>
<br><font size=2 face="sans-serif"> location /data/ {</font>
<br><font size=2 face="sans-serif"> root /usr/local;</font>
<br><font size=2 face="sans-serif"> internal;</font>
<br><font size=2 face="sans-serif"> proxy_hide_header X-Accel-Redirect;</font>
<br><font size=2 face="sans-serif"> add_header ETag $upstream_http_etag;</font>
<br><font size=2 face="sans-serif"> }</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"> public
String file() {</font>
<br><font size=2 face="sans-serif">
response.setHeader("X-Accel-Charset",
"utf-8");</font>
<br><font size=2 face="sans-serif">
response.setHeader("X-Accel-Redirect",
path);</font>
<br>
<br><font size=2 face="sans-serif">
return NONE;</font>
<br><font size=2 face="sans-serif"> }</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() "/usr/local/data/WH2HOSIPTV/遄.txt" 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: "GET
/update/download/WH2HOSIPTV/%E6%97%A5%E5%BF%97.txt HTTP/1.1", upstream:
"http://127.0.0.1:8080/update/download.action?path=WH2HOSIPTV/%e6%97%a5%e5%bf%97.txt",
host: "update.grandes.com.cn".</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"> public
String file() {</font>
<br><font size=2 face="sans-serif">
response.setHeader("X-Accel-Charset",
"utf-8");</font>
<br><font size=2 face="sans-serif">
response.setHeader("X-Accel-Redirect",
new String(path.getBytes("utf-8"), "iso-8859-1"));</font>
<br>
<br><font size=2 face="sans-serif">
return NONE;</font>
<br><font size=2 face="sans-serif"> }</font>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">Best regards</font>