Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nginx 两个上游,一个http,另一个https_Nginx_Lua_Openresty - Fatal编程技术网

Nginx 两个上游,一个http,另一个https

Nginx 两个上游,一个http,另一个https,nginx,lua,openresty,Nginx,Lua,Openresty,大家好! 我在设置openresty时遇到一个问题,请帮助。 我拥有的:openresty+lua。 Openresty配置: upstream a { server 1.1.8.1:4707; } upstream c { server 1.1.8.1:4707; } server { location / { proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $h

大家好! 我在设置openresty时遇到一个问题,请帮助。 我拥有的:openresty+lua。 Openresty配置:

upstream a {
   server 1.1.8.1:4707;
}

upstream c {
   server 1.1.8.1:4707;
}
server {
location / {
   proxy_set_header X-Forwarded-Host $host;
   proxy_set_header X-Forwarded-Server $host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Url-Scheme $scheme;
   proxy_set_header X-Forwarded-Proto $scheme;
   proxy_set_header Host $http_host;
   proxy_redirect off;
   proxy_ssl_verify off;
   if ($request_method = POST ) {
   set $upstream '';
   access_by_lua '
   ngx.req.read_body()
   local  match0 = ngx.re.match(ngx.var.request_body, "aaa.*")
   local  match1 = ngx.re.match(ngx.var.request_body, "bbb.*")
   if match0 then
      ngx.var.upstream = "a"
   else
      ngx.var.upstream = "c"
   end
   ';
   proxy_pass http://$upstream;
   }
}
}
目标:根据传递的请求方法将请求分发到上游。请求以json rpc格式发送。 问题:我有两条上游。一个上游是通过http协议提供的,另一个是通过https提供的,我没有遇到以下问题,一次只有一个上游工作。 即使创建单独的类似配置,也只有1个可用,1个可用。 如果有人遇到,请帮忙。 如何指定通过不同协议可用的多个上游?或者我没有正确注册配置? 甚至openresty设置中指定的指令“proxy\u ssl\u verify off”也没有帮助
提前谢谢。

看看我的答案

您可以使用不同的上游和代理服务器配置2个内部位置,并通过
ngx.exec()
Lua API执行内部重定向,最好是在
rewrite\u by\u块的上下文中