前言:
此文的读者定义为对openresty有一定了解的读者。
openresty:
https://github.com/openresty/lua-nginx-module
此文要讲什么:
大家都知道openresty可以用ngx.location.capture和ngx.exec来实现内部跳转,
下面要讲怎么将ngx.location.capture和ngx.exec与upstream模块结合起来,实现一个动态的upstream。
下面的演示中:
80端口表示首次请求入口
8080端口表示upstream的出口
直接上配置和源码:
配置: conf/nginx.conf
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
log_format main '$msec $status $request $request