Welcome! Log In Create A New Profile


40 bad request and UTF8

September 25, 2013 08:13AM

Im using nginx and rails for my site which contains url with georgian letters ie განცხადებები so something like http://gancxadebebi.ge/ka/%E1%83%92%E1%83%90%E1%83%9C%E1%83%AA%E1%83%AE%E1%83%90%E1%83%93%E1%83%94%E1%83%91%E1%83%94%E1%83%91%E1%83%98
It is mainly working perfectly but sometimes I receive request with truncated url ie
1 - http://gancxadebebi.ge/ka/%E1%83%92%E1%83%90%E1%83%9C%E1%83%AA%E1%83%AE%E1%83%90%E1%83%93%E1%83%94%E1%83%91%E1%83%94%E1%83%91%E1%83%9
(as u can see it should be something after %9)
2 - http://gancxadebebi.ge/ka/%E1%83%92%E1%83%90%E1%83%9C%E1%83%AA%E1%83%AE%E1%83%90%E1%83%93%E1%83%94%E1%83%91%E1%83%94%E1%83%91%E1%83%98?mc=mini+aipadi&search=%E1%83%AB%E1%83%98%E1%83%94%E1%83%91%E1%83%9

I succeeded to deal when there is no get parameters (first url above) and make in that case a redirection to /
when this happen, this line is added to nginx error.log
2013/09/24 00:46:53 [alert] 63547#0: *19359227 pcre_exec() failed: -10 on "/ka/განცხადებებ�" using "", client: aa.bb.cc.dd, server: gancxadebebi.ge, request: "GET /ka/%E1%83%92%E1%83%90%E1%83%9C%E1%83%AA%E1%83%AE%E1%83%90%E1%83%93%E1%83%94%E1%83%91%E1%83%94%E1%83%91%E1%8 HTTP/1.1", host: "gancxadebebi.ge"

but for second url, which have get parameter truncated, I can not handle that which generate a 400 bad request page.
such request added this line in nginx access.log
aa.bb.cc.dd - - [24/Sep/2013:00:48:47 +0200] "GET /ka/%E1%83%92%E1%83%90%E1%83%9C%E1%83%AA%E1%83%AE%E1%83%90%E1%83%93%E1%83%94%E1%83%91%E1%83%94%E1%83%91%E1%83%98?mc=mini+aipadi&search=%E1%83%AB%E1%83%98%E1%83%94%E1%83%91%E1%83% HTTP/1.1" 400 5 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36"

does this mean that nginx accepted the request and then rails coudnt resolve it ?

I don't know if problem come from rails or from nginx. For first url, I solved it in nginx conf
here part of my conf

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

client_body_in_file_only clean;
client_body_buffer_size 32K;
charset UTF-8;
source_charset UTF-8;
client_max_body_size 300M;

error_page 400 404 = @notfound;
error_page 500 502 504 = @server_error;
error_page 503 = @maintenance;

location @notfound {
rewrite ^(.*)$ $scheme://$host permanent;

location @server_error {
rewrite ^(.*)$ $scheme://$host permanent;

location @maintenance {
rewrite ^(.*)$ $scheme://$host permanent;
sendfile on;
send_timeout 300s;

location / {
proxy_pass http://gancx;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
charset UTF-8;
client_max_body_size 7m;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;

thanks for your help

40 bad request and UTF8

optimum.dulopinSeptember 25, 2013 08:13AM

Re: 40 bad request and UTF8

Maxim DouninSeptember 25, 2013 10:06AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 83
Record Number of Users: 6 on March 20, 2015
Record Number of Guests: 148 on March 24, 2015
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready