# X-Accel-Redirect can't deal with un-ascii file name

**URL:** <https://www.ruby-forum.com/t/x-accel-redirect-cant-deal-with-un-ascii-file-name/205482>\
**Category:** NGINX\
**Created:** [April 7, 2011, 12:33pm UTC](https://www.ruby-forum.com/t/x-accel-redirect-cant-deal-with-un-ascii-file-name/205482 "2011-04-07T12:33:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 7, 2011, 12:33pm UTC](https://www.ruby-forum.com/t/x-accel-redirect-cant-deal-with-un-ascii-file-name/205482/1 "2011-04-07T12:33:05Z")

</div>

Hi, all!  
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:

server {  
listen 80;  
server\_name [update.grandes.com.cn](http://update.grandes.com.cn);  
access\_log logs/grandes\_access.log main;  
location /update/download {  
rewrite ^/update/download/(.+)$ /update/download.action?path=$1  
last;  
proxy\_pass [http://localhost:8080](http://localhost:8080);  
proxy\_redirect off;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header Host $http\_host;  
client\_max\_body\_size 10240m;  
client\_body\_buffer\_size 128k;

```
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;

proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;

```

}  
location /h3/ {  
root /usr/local/data;  
internal;  
proxy\_hide\_header X-Accel-Redirect;  
add\_header ETag $upstream\_http\_etag;  
}  
}

And this’s the code of ‘/update/download.action’ running in tomcat  
server,

```
    public String file() {
            response.setHeader("X-Accel-Charset", "utf-8");
            response.setHeader("X-Accel-Redirect", path);

            return NONE;
    }

```

When access the path  
‘[http://update.grandes.com.cn/update/download/WH2HOSIPTV/日志.txt](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,  
but the nginx log track like this;  
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](http://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/日志.txt](http://127.0.0.1:8080/update/download.action?path=WH2HOSIPTV/%e6%97%a5%e5%bf%97.txt)”,  
host: “[update.grandes.com.cn](http://update.grandes.com.cn)”.

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?

```
    public String file() {
            response.setHeader("X-Accel-Charset", "utf-8");
            response.setHeader("X-Accel-Redirect", new

```

String(path.getBytes(“utf-8”), “iso-8859-1”));

```
            return NONE;
    }

```

Best regards
