openresty中capture_multi如何与upstream结合使用?
来源:互联网 发布:淘宝客服对话案例 编辑:程序博客网 时间:2024/06/05 01:09
把前端的请求经由nginx多路转发给后台的apache以及tomcat服务器,然后对后台服务器返回的数据做一些归并和排序处理。
下面是nginx.conf配置。
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 51200;
}
http {
upstream cluster_1 { //apache servers
server localhost:10001;
}
upstream cluster_2 { //tomcat servers
server localhost:10002;
}
server {
listen 10000;
server_name localhost;
location /multi {
proxy_pass_request_headers off;
content_by_lua '
local res1, res2 = ngx.location.capture_multi{
{ "/s1" },
{ "/s2" },
}
ngx.say(res1.status);
if res1.status == ngx.HTTP_OK then
ngx.print(res1.body);
end
';
}
location /s2 {
proxy_pass http://cluster_2;
}
}
}
下面是nginx.conf配置。
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 51200;
}
http {
upstream cluster_1 { //apache servers
server localhost:10001;
}
upstream cluster_2 { //tomcat servers
server localhost:10002;
}
server {
listen 10000;
server_name localhost;
location /multi {
proxy_pass_request_headers off;
content_by_lua '
local res1, res2 = ngx.location.capture_multi{
{ "/s1" },
{ "/s2" },
}
ngx.say(res1.status);
if res1.status == ngx.HTTP_OK then
ngx.print(res1.body);
end
';
}
location /s2 {
proxy_pass http://cluster_2;
}
}
}
0 0
- openresty中capture_multi如何与upstream结合使用?
- 用openresty实现动态upstream
- Android中 PopupWindow 与 ListView 结合使用
- 利用openresty-lua生态修改upstream后端服务
- 利用 openresty balancer_by_lua 实现一个简单的 ip_hash upstream 调度
- C++如何更好的与XML结合使用
- OpenResty 中不当使用 MySQL 连接池导致事务被回滚
- nginx upstream 配置使用
- NGINX 结合 lua 动态修改upstream
- NGINX 结合 lua 动态修改upstream
- OpenResty初步使用
- openresty的初步使用
- 《深入理解Nginx》阅读与实践 使用upstream和subrequest访问第三方服务 no port in upstream
- datagrid与DataSet结合使用中出现的索引问题
- datagrid与DataSet结合使用中出现的索引问题
- WinForm程序中多线程与Timer的结合使用
- Android中关于DatePickerDialog与TimePickerDialog的结合使用
- Android中关于DatePickerDialog与TimePickerDialog的结合使用
- Linux C工程管理 之autoconf与automake
- pcre-8.36/missing:行81: aclocal-1.14: 未找到命令
- Method Reference in Java 8
- caffe安装吐血总结 opencv的问题,ubuntu版本问题
- 知识库--The Loader Interface(47)
- openresty中capture_multi如何与upstream结合使用?
- 改进了自行车
- 一目了然 AI和PS的区别
- 基本运算
- 安全哈希算法SHA1
- 最长上升子序列
- 有效回文串,lintcode
- 自定义函数的登记
- grep用法详解 grep与正则表达式