server {
server_name ivr.com;
access_log /home/work/log/nginx/access.ivr.log;
error_log /home/work/log/nginx/error.ivr.log;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 30;
proxy_connect_timeout 10;
location /ivr/ {
lua_code_cache off;
resolver 8.8.8.8;
set $backend '';
rewrite_by_lua_file /home/work/tengine-2.1.0/conf/lua/ivr.lua;
proxy_pass http://$backend;
}
}
local redis = require "resty.redis"
local cjson = require "cjson"
local cache = redis.new()
cache.connect(cache, '127.0.0.1', '6379')
local args = ngx.req.get_uri_args()
local uri = ngx.var.request_uri
local callid = nil
local channel = 0
if string.find(uri, 'yuntongxun') then
callid = args["callid"]
channel = 0
elseif string.find(uri, 'yunhu') then
ngx.req.read_body()
local body_data = ngx.req.get_body_data()
local data = cjson.decode(body_data)
callid = data['call_id']
channel = 1
elseif string.find(uri, 'huawei') then
callid = args["vSessionsId"]
channel = 2
else
end
if callid == nil then
ngx.say(uri)
ngx.say(cjson.encode(args))
ngx.say('callid is empty')
return ''
end
local key = callid .. '_channel' .. channel
local res = cache:get(key)
if res == ngx.null then
ngx.say("cache get error")
return ''
end
ngx.var.backend = res
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有