-
server {
-
listen 80;
-
server_name *.bh.cn;
-
-
set $geta "";
-
location /iask/ {
-
set_md5 $md5 $host$request_uri;
-
set $geta $request_uri;
-
set $redis_key $md5;
-
redis_pass 10.1.102.232:9221;
-
add_header "file-md5" $md5;
-
default_type text/html;
-
error_page 404 = /fallback?url=$geta;
-
}
-
-
location = /fallback {
-
set $redis_host "10.1.102.232";
-
set $geta $arg_url;
-
set $val "";
-
set_md5 $md5 $host$geta;
-
content_by_lua_block{
-
local redis = require "redis_red"
-
local red = redis:new()
-
local url = string.gsub(ngx.var.geta, "iask", "miask")
-
local res = ngx.location.capture(url);
-
--ngx.say(res.status)
-
local val = res.body
-
red:set(ngx.var.md5, val)
-
red:expire(ngx.var.md5, 3600) --缓存时间
-
ngx.say(val)
-
--ngx.say(url)
-
}
-
-
}
-
-
location /miask/ {
-
proxy_pass http://127.0.0.1:88/iask/;
-
proxy_set_header Host "m.bh.cn";
-
}
-
-
-
}
通过ngx_http_reids,将页面缓存的PIKA中。
阅读(678) | 评论(0) | 转发(0) |