Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

nginx+ssi+redis_lua странное поведение

$
0
0
в конфиге хоста стоит:
ssi on;

сделан локейшн:
[code] location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}

location ~ ^/system/templates/(?<template>.*)$ {
# internal;
# add_header Content-Type text/html;

content_by_lua '
local redis = require "resty.redis"
local red = redis:new()
red:set_timeout(1000) -- 1 sec
-- or connect to a unix domain socket file listened
-- by a redis server:
-- local ok, err = red:connect("unix:/path/to/redis.sock")
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.say("failed to connect: ", err);
return;
end

local res, err = red:get("system:templates:" .. ngx.var.template);
if not res then
ngx.say("failed to get template: " .. ngx.var.template)
return
end
if res == ngx.null then
ngx.say("template not found." .. ngx.var.template)
return
end
ngx.say(res);
';
}
[/code]

кладем файл redis-test.html в корень сайта
[code]<!--# include virtual="/system/templates/header.tpl" -->
<h1>Тестируем nginx + redis + ssi</h1>

<div>
<!--# include virtual="/system/templates/news.tpl" -->
</div>

<!--# include virtual="/system/templates/footer.tpl" -->
[/code]

в redis в ключах system:templates:header.tpl , news.tpl. footer.tpl - прописан текст.

если вручную идти в локейшны /system/... - выводится нужный текст. через ssi - всё гораздо интересней. вставляется случайный кусок 3 раза. обычно это бывает footer.tpl.

может я что-то не так делаю? подскажите гуру.

Viewing all articles
Browse latest Browse all 53287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>