先贴个当前的server demo:
server {
listen 80 default backlog=65535;
server_name ~.*;
access_by_lua_file /openresty/lua/access/access.lua;
body_filter_by_lua_file /openresty/lua/body_filter/body_filter.lua;
log_by_lua_file /openresty/lua/log_phase/log.lua;
location / {
proxy_pass http://ats;
}
location ~* .*\.(mp4|flv)$ {
content_by_lua_file /openresty/lua/video/proxy.lua;
break;
}
}
当前以此server提供服务,如请求 http://www.baidu.com/a/b?arg=name, 现要兼容302调度的请求,如请求http://192.168.100.142/www.baidu.com/a/b?arg=val。302调度的请求只是比非302调度请求前多了个服务器ip。请问该如何兼容302调度的请求?
现有两种方案,一是使用指令对302请求进行rewrite,问题是lua逻辑中多处使用诸如ngx.var.request_uri的变量。另一种是使用前端在开一个server 专门处理302调度请求,用它去除ip后访问现在的server。问题是如何匹配302调度请求(即ip为host的请求)进新server中,及在server中记录日志的问题。请评估使用哪种方案,是否有其他好的方案?谢谢~