Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nginx+captcha
В общем порылся в дебаглоге, получается
следующая картинка:
это кусок лога, записанный при вводе
капчи в ФФ
[code]
2010/07/16 08:19:56 [debug] 5412#0: *1 http keepalive handler
2010/07/16 08:19:56 [debug] 5412#0: *1 malloc: 0000000801409400:1024
2010/07/16 08:19:56 [debug] 5412#0: *1 recv: eof:0, avail:446, err:0
2010/07/16 08:19:56 [debug] 5412#0: *1 recv: fd:3 446 of 1024
2010/07/16 08:19:56 [debug] 5412#0: *1 malloc: 0000000801446C00:1256
2010/07/16 08:19:56 [debug] 5412#0: *1 event timer del: 3:
1279268436782
2010/07/16 08:19:56 [debug] 5412#0: *1 generic phase: 0
2010/07/16 08:19:56 [debug] 5412#0: *1 add cleanup: 0000000801439B78
2010/07/16 08:19:56 [debug] 5412#0: *1 generic phase: 1
2010/07/16 08:19:56 [debug] 5412#0: *1 test location: "/"
2010/07/16 08:19:56 [debug] 5412#0: *1 test location: "rcaptcha/"
2010/07/16 08:19:56 [debug] 5412#0: *1 using configuration "/rcaptcha/"
2010/07/16 08:19:56 [debug] 5412#0: *1 http cl:-1 max:1048576
2010/07/16 08:19:56 [debug] 5412#0: *1 generic phase: 3
2010/07/16 08:19:56 [debug] 5412#0: *1 http script var
2010/07/16 08:19:56 [debug] 5412#0: *1 perl variable handler
2010/07/16 08:19:56 [debug] 5412#0: *1 perl variable done
2010/07/16 08:19:56 [debug] 5412#0: *1 http script var: "1"
2010/07/16 08:19:56 [debug] 5412#0: *1 http script value: "1"
2010/07/16 08:19:56 [debug] 5412#0: *1 http script equal
2010/07/16 08:19:56 [debug] 5412#0: *1 http script if
2010/07/16 08:19:56 [debug] 5412#0: *1 http script regex: "^"
2010/07/16 08:19:56 [notice] 5412#0: *1 "^" matches "/rcaptcha/",
client: 192.168.50.1, server: sec.grt, request: "GET
/rcaptcha/?input=aaa123 HTTP/1.1", host: "sec.grt", referrer:
"http://sec.grt/"
2010/07/16 08:19:56 [debug] 5412#0: *1 parse header: "Cookie: fu=/;
ct=3731520923"
2010/07/16 08:19:56 [debug] 5412#0: *1 http script var: "/"
2010/07/16 08:19:56 [debug] 5412#0: *1 http script regex end
2010/07/16 08:19:56 [notice] 5412#0: *1 rewritten redirect:
"/?input=aaa123", client: 192.168.50.1, server: sec.grt, request: "GET
/rcaptcha/?input=aaa123 HTTP/1.1", host: "sec.grt", referrer:
"http://sec.grt/"
2010/07/16 08:19:56 [debug] 5412#0: *1 http finalize request: 302,
"/rcaptcha/?input=aaa123" 1
2010/07/16 08:19:56 [debug] 5412#0: *1 http special response: 302,
"/rcaptcha/?input=aaa123"
2010/07/16 08:19:56 [debug] 5412#0: *1 http set discard body
2010/07/16 08:19:56 [debug] 5412#0: *1 perl variable handler
2010/07/16 08:19:56 [debug] 5412#0: *1 perl variable done
2010/07/16 08:19:56 [debug] 5412#0: *1 http script copy: "ha="
2010/07/16 08:19:56 [debug] 5412#0: *1 http script var: "1208981956"
2010/07/16 08:19:56 [debug] 5412#0: *1 http script copy: "; path=/"
2010/07/16 08:19:56 [debug] 5412#0: *1 HTTP/1.1 302 Moved Temporarily
Server: nginx/0.7.67
Date: Fri, 16 Jul 2010 08:19:56 GMT
Content-Type: text/html
Content-Length: 161
Location: http://sec.grt/?input=aaa123
Connection: keep-alive
Set-Cookie: ha=1208981956; path=/
[/code]
то есть все как надо, ha кука ставится, и
дальше все работает
а вот кусок дебага при том-же запросе
через Хром
[code]
2010/07/16 08:21:01 [debug] 5412#0: *1 http keepalive handler
2010/07/16 08:21:01 [debug] 5412#0: *1 close http connection: 3
2010/07/16 08:21:01 [debug] 5412#0: *1 free: 0000000000000000
2010/07/16 08:21:01 [debug] 5412#0: *1 free: 0000000000000000
2010/07/16 08:21:01 [debug] 5412#0: *1 free: 000000080149D600, unused:
8
2010/07/16 08:21:01 [debug] 5412#0: *1 free: 000000080149D700, unused:
112
2010/07/16 08:21:03 [debug] 5412#0: *4 event timer del: 3:
1279268523279
2010/07/16 08:21:03 [debug] 5412#0: *4 generic phase: 0
2010/07/16 08:21:03 [debug] 5412#0: *4 add cleanup: 0000000801439B70
2010/07/16 08:21:03 [debug] 5412#0: *4 generic phase: 1
2010/07/16 08:21:03 [debug] 5412#0: *4 test location: "/"
2010/07/16 08:21:03 [debug] 5412#0: *4 test location: "rcaptcha/"
2010/07/16 08:21:03 [debug] 5412#0: *4 using configuration "/rcaptcha/"
2010/07/16 08:21:03 [debug] 5412#0: *4 http cl:-1 max:1048576
2010/07/16 08:21:03 [debug] 5412#0: *4 generic phase: 3
2010/07/16 08:21:03 [debug] 5412#0: *4 http script var
2010/07/16 08:21:03 [debug] 5412#0: *4 perl variable handler
2010/07/16 08:21:03 [debug] 5412#0: *4 perl variable done
[b]2010/07/16 08:21:03 [debug] 5412#0: *4 http script var: "0"[/b]
<-------------- что-бы все работало, тут должна
быть 1 как я понимаю, но сравнение
возвращает 0
2010/07/16 08:21:03 [debug] 5412#0: *4 http script value: "1"
2010/07/16 08:21:03 [debug] 5412#0: *4 http script equal
2010/07/16 08:21:03 [debug] 5412#0: *4 http script equal: no
2010/07/16 08:21:03 [debug] 5412#0: *4 http script if
2010/07/16 08:21:03 [debug] 5412#0: *4 http script if: false
2010/07/16 08:21:03 [debug] 5412#0: *4 http script regex: "^"
2010/07/16 08:21:03 [notice] 5412#0: *4 "^" matches "/rcaptcha/",
client: 192.168.50.1, server: sec.grt, request: "GET
/rcaptcha/?input=bbb123 HTTP/1.1", host: "sec.grt", referrer:
"http://sec.grt/"
2010/07/16 08:21:03 [debug] 5412#0: *4 http script copy: "/test.html"
2010/07/16 08:21:03 [debug] 5412#0: *4 http script regex end
2010/07/16 08:21:03 [notice] 5412#0: *4 rewritten redirect:
"/test.html?input=bbb123", client: 192.168.50.1, server: sec.grt,
request: "GET /rcaptcha/?input=bbb123 HTTP/1.1", host: "sec.grt",
referrer: "http://sec.grt/"
2010/07/16 08:21:03 [debug] 5412#0: *4 http finalize request: 302,
"/rcaptcha/?input=bbb123" 1
2010/07/16 08:21:03 [debug] 5412#0: *4 http special response: 302,
"/rcaptcha/?input=bbb123"
2010/07/16 08:21:03 [debug] 5412#0: *4 http set discard body
2010/07/16 08:21:03 [debug] 5412#0: *4 HTTP/1.1 302 Moved Temporarily
Server: nginx/0.7.67
Date: Fri, 16 Jul 2010 08:21:03 GMT
Content-Type: text/html
Content-Length: 161
Location: http://sec.grt/test.html?input=bbb123
Connection: keep-alive
[/code]
а вот локейшн и обработчик, которые
отвечают за проверку
[code]
location /rcaptcha/ {
if ( $check_input ) {
add_header Set-Cookie "ha=$crc32_ha; path=/";
rewrite ^ $cookie_fu redirect;
}
rewrite ^ /test.html redirect;
}
perl_set $check_input '
sub {
use String::CRC32;
my $r = shift;
my $input=$r->args;
$input=~ s/.*input=(.+)/$1/g;
my $cookie_ct=$r->header_in("Cookie");
$cookie_ct=~ s/.+ct=([^\ ]+).*/$1/g;
if ( $cookie_ct == crc32($input.$r->remote_addr) ) { return 1; }
else { return 0; }
}';
[/code]
товарищи, подскажите, где собака
порылвсь..? чем Хром так отличается от
Оперы и ФФ ?
Posted at Nginx Forum:
http://forum.nginx.org/read.php?21,95997,109610#msg-109610
_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://nginx.org/mailman/listinfo/nginx-ru
|