Re: userid. $uid_set ,

Konstantin Tokarev annulen at yandex.ru
Thu Mar 12 16:28:28 UTC 2015



12.03.2015, 19:24, "Den Bozhok" <undying-m at yandex.ru>:
>     ,   .
>
> .. Lua    ,     ,        + API  nginx.      :
>
> server {
>
> listen 80;
>
> userid on;
>
> location / {
> proxy_pass http://172.17.42.1:9292;
> proxy_set_header X-Uid-Got $uid_got;
> proxy_set_header X-Uid-Set $uid_set;
>
> set $user_cookie $http_cookie;
>
> if ($uid_set) {
> set_by_lua $user_cookie '
> function encode_cookie(cookie)
> local binary_string = ""
> for i=5,35,8 do
> local chunk = tonumber(string.sub(cookie, i, i+7), 16)

  :

local chunk = tonumber(cookie:sub(i, i+7), 16)

>
> for j=1,4 do
> binary_string = binary_string .. string.char(chunk % 256)
> chunk = math.floor(chunk / 256)
> end
> end
>
> return ngx.encode_base64(binary_string)
> end
>
> if ngx.var.http_cookie == nil then
> return encode_cookie(ngx.var.uid_set)
> else
> return ngx.var.http_cookie .. ";" .. encode_cookie(ngx.var.uid_set)
> end
> ';
> }
>
> proxy_set_header Cookie $user_cookie;
> }
>
> }
>
> 11.03.2015, 19:48, "Den Bozhok" <undying-m at yandex.ru>:
>>  !
>>
>>  ,    nginx,   $uid_set     Base64,       Set-Cookie?
>>
>>     uid     ,       .
>>    lua ,       :/
>>
>> !
>> ,
>>
>> _______________________________________________
>> nginx-ru mailing list
>> nginx-ru at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru

-- 
Regards,
Konstantin



nginx-ru