Opened 3 years ago

Closed 3 years ago

#787 closed defect (invalid)

Nginx not able to properly handle charater-set encoding

Reported by: stackoverflow.com/users/5159092/rajdeep-bhattacharya Owned by:
Priority: major Milestone:
Component: nginx-core Version: 1.8.x
Keywords: Cc:
uname -a: Linux ngxint00 3.2.0-0.bpo.4-amd64 #1 SMP Debian 3.2.46-1+deb7u1~bpo60+1 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.8.0 built by gcc 4.4.5 (Debian 4.4.5-8) built with OpenSSL 0.9.8o 01 Jun 2010 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-cc-opt='-g -O2 -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt=-Wl,--as-needed --with-ipv6

Description

We are trying to forward some arabic character in the uri. The flow of request is :-

Nginx (Proxy) -> Tomcat Banckend

The url is something like http://x1.example.com/v1/test/حـرآمے^_^بـنـآت.
Now in the output of the nginx log I am getting something like this :-

10.31.0.250 - - [14/Sep/2015:12:12:24 +0000]"PUT /v1/test/%D8%AD%D9%80%D8%B1%D8%A2%D9%85%DB%92%5E_%5E%D8%A8%D9%80%D9%86%D9%80%D8%A2%D8%AA HTTP/1.1" 405 568 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit?/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36" - Time: 0.169

In the backend tomcat the logs is something like this :-

SEVERE: Servlet.service() for servlet CXFServlet threw exception
java.lang.IllegalArgumentException?: Illegal character in path at index 53: http://badges_cluster/badges-service-web/v1/badge/حـرآÙ
ے_بـنـآت
at java.net.URI.create(URI.java:859)

And in the response code it throws a 500 exception. The applicaiton is not able to understand the request as they are all junk charcters for it. Now we have enabled utf-8 character encoding in the nginx.conf

http {

include /etc/nginx/mime.types;
charset utf-8;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

ignore_invalid_headers on;

# client_header_timeout 1;

client_header_timeout 10;

# client_body_timeout 2;

client_body_timeout 10;
server_tokens off;
sendfile on;
tcp_nodelay on;
tcp_nopush on;

# keepalive_timeout 0;

keepalive_timeout 0;

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

But still doesn't help.

Change History (1)

comment:1 Changed 3 years ago by mdounin

  • Resolution set to invalid
  • Status changed from new to closed

From the report it looks like the problem is that backend is unable to handle the request, not nginx. It doesn't looks like a bug in nginx.

Note that this Trac is to track bugs in nginx, not to ask for help with nginx configuration. If you need help, consider asking in the mailing list instead.

Note: See TracTickets for help on using tickets.