您好, 请问当下游也是tcp时候,结合lua归并上游请求。tcp这块怎么弄呢?谢谢!
------------------ 原始邮件 ------------------发件人: "阳光梦"<4647...@qq.com>发送时间: 2016年12月12日(星期一) 上午9:01收件人: "openresty"<openresty@googlegroups.com>;主题: 回复: [openresty] openresty中capture_multi如何与upstream结合使用?thanks 参考您的代码已经有解决办法了, 结合upstream即可。 自己写个类似redis_pass指令对应的模块即可。 现在问题是: 1,当后端有的服务器down掉,需要访问备机怎么办? 2, 当后端服务器中部分down掉, 需要将其他机器的结果归并回复客户端。 你有什么好的办法没?------------------ 原始邮件 ------------------发件人: "DeJiang Zhu";<douj...@gmail.com>;发送时间: 2016年12月11日(星期天) 晚上9:24收件人: "openresty"<openresty@googlegroups.com>; 主题: Re: [openresty] openresty中capture_multi如何与upstream结合使用?Hello你需要自己写 Lua 代码来实现比如用 resty.redis 跟 redis 去通讯,同时你可以使用 ngx.thread 来并发向后端通讯具体的用法,你可以去查对应的文档,应该是没有一个现成的实现在 2016年12月11日 下午12:39, <4647...@qq.com>写道:您好, 请教下, 如果后端服务器是任意的tcp服务器呢。比如redis和mongodb服务器, 需要归并结果,怎么处理呢?在 2012年5月4日星期五 UTC+8下午4:50:49,JackieJIANG写道:Hi agentzh; 我想把前端的请求经由nginx多路转发给后台的apache以及tomcat服务器,然后对后台服务器返回的数据做一些归并和排序处理。在实验的时 候,遇到了如下问题, 2012/05/04 16:09:57 [error] 1195#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 61.135.152.195, server: localhost, request: "GE\ T /multi HTTP/1.1", subrequest: "/s1", upstream: "http:// 127.0.0.1:10001/s1", host: "XXXXX.XXXX.XXXX.XXXX:10000" 请问,为何请求是发给http://127.0.0.1:10001/s1,而不是http://127.0.0.1:10001呢? 谢谢啦! 下面是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; } } } -- -- -- --
您好, 请教下, 如果后端服务器是任意的tcp服务器呢。比如redis和mongodb服务器, 需要归并结果,怎么处理呢?在 2012年5月4日星期五 UTC+8下午4:50:49,JackieJIANG写道:Hi agentzh; 我想把前端的请求经由nginx多路转发给后台的apache以及tomcat服务器,然后对后台服务器返回的数据做一些归并和排序处理。在实验的时 候,遇到了如下问题, 2012/05/04 16:09:57 [error] 1195#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 61.135.152.195, server: localhost, request: "GE\ T /multi HTTP/1.1", subrequest: "/s1", upstream: "http:// 127.0.0.1:10001/s1", host: "XXXXX.XXXX.XXXX.XXXX:10000" 请问,为何请求是发给http://127.0.0.1:10001/s1,而不是http://127.0.0.1:10001呢? 谢谢啦! 下面是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; } } } --
Hi agentzh; 我想把前端的请求经由nginx多路转发给后台的apache以及tomcat服务器,然后对后台服务器返回的数据做一些归并和排序处理。在实验的时 候,遇到了如下问题, 2012/05/04 16:09:57 [error] 1195#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 61.135.152.195, server: localhost, request: "GE\ T /multi HTTP/1.1", subrequest: "/s1", upstream: "http:// 127.0.0.1:10001/s1", host: "XXXXX.XXXX.XXXX.XXXX:10000" 请问,为何请求是发给http://127.0.0.1:10001/s1,而不是http://127.0.0.1:10001呢? 谢谢啦! 下面是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; } } }
”请参考我的上一篇回复”, 可以发行url吗?,谢谢!
------------------ 原始邮件 ------------------发件人: "DeJiang Zhu";<douj...@gmail.com>;发送时间: 2016年12月13日(星期二) 下午2:49收件人: "openresty"<openresty@googlegroups.com>; 主题: Re: [openresty] openresty中capture_multi如何与upstream结合使用?Hello在 2016年12月12日 下午8:23,阳光梦 <4647...@qq.com>写道:您好, 请问当下游也是tcp时候,结合lua归并上游请求。tcp这块怎么弄呢?谢谢!请参考我的上一篇回复最灵活的方式是用 Lua 是实现,只是用上 stream_lua_module 即可 ------------------ 原始邮件 ------------------发件人: "阳光梦"<4647...@qq.com>发送时间: 2016年12月12日(星期一) 上午9:01收件人: "openresty"<openresty@googlegroups.com>;主题: 回复: [openresty] openresty中capture_multi如何与upstream结合使用?thanks 参考您的代码已经有解决办法了, 结合upstream即可。 自己写个类似redis_pass指令对应的模块即可。 现在问题是: 1,当后端有的服务器down掉,需要访问备机怎么办? 2, 当后端服务器中部分down掉, 需要将其他机器的结果归并回复客户端。 你有什么好的办法没?------------------ 原始邮件 ------------------发件人: "DeJiang Zhu";<douj...@gmail.com>;发送时间: 2016年12月11日(星期天) 晚上9:24收件人: "openresty"<openresty@googlegroups.com>; 主题: Re: [openresty] openresty中capture_multi如何与upstream结合使用?Hello你需要自己写 Lua 代码来实现比如用 resty.redis 跟 redis 去通讯,同时你可以使用 ngx.thread 来并发向后端通讯具体的用法,你可以去查对应的文档,应该是没有一个现成的实现在 2016年12月11日 下午12:39, <4647...@qq.com>写道:您好, 请教下, 如果后端服务器是任意的tcp服务器呢。比如redis和mongodb服务器, 需要归并结果,怎么处理呢?在 2012年5月4日星期五 UTC+8下午4:50:49,JackieJIANG写道:Hi agentzh; 我想把前端的请求经由nginx多路转发给后台的apache以及tomcat服务器,然后对后台服务器返回的数据做一些归并和排序处理。在实验的时 候,遇到了如下问题, 2012/05/04 16:09:57 [error] 1195#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 61.135.152.195, server: localhost, request: "GE\ T /multi HTTP/1.1", subrequest: "/s1", upstream: "http:// 127.0.0.1:10001/s1", host: "XXXXX.XXXX.XXXX.XXXX:10000" 请问,为何请求是发给http://127.0.0.1:10001/s1,而不是http://127.0.0.1:10001呢? 谢谢啦! 下面是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; } } } -- -- -- -- -- --