我在我的网站上使用 nginx 和 rails,其中包含带有格鲁吉亚字母的 url,即 განცხადებები,例如 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 它主要工作得很好,但有时我收到截断 url 的请求,即 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 (如您所见,它应该在 %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&搜索=%E1%83%AB%E1%83%98%E1%83%94%E1%83%91%E1%83%9
当没有获取参数(上面的第一个 url)时我成功处理并在这种情况下重定向到 / 发生这种情况时,此行添加到 nginx error.log 2013/09/24 00:46:53 [alert] 63547#0: *19359227 pcre_exec() 失败:-10 在“/ka/განცხადებებ�”上使用“”,客户端:aa.bb.cc.dd,服务器:gancxadebebi.ge,请求:“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”,主机:“gancxadebebi.ge”
但是对于第二个 url,它的参数被截断,我无法处理生成 400 错误请求页面的内容。这样的请求在 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"
这是否意味着 nginx 接受了请求,然后 rails coudnt 解决了它?
我不知道问题是来自 rails 还是来自 nginx。对于第一个 url,我在 nginx conf 中解决了它,这是我的 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;
}
感谢您的帮助