nginx auth_request_set不允许在上下文中测试变量



我正在寻找FCGI授权器的工作,这就是我的测试配置的外观:

        location ~* "f4m$" {
                limit_except GET {
                        deny all;
                }
                auth_request /clu;
                auth_request_set $node $upstream_http_server;
# Problem's that $node is always empty for <if> in this context
                proxy_set_header Node $node;
                proxy_pass http://127.0.0.1/group_1tv$request_uri;
        }
        location = /clu {
                internal;
                proxy_pass_request_body off;
                proxy_pass_request_headers off;
                proxy_set_header Content-Length '';
                proxy_pass http://cluster_authorizer$request_uri;
        }
}

,如果我可以在返回后立即使用if结构测试可变的$node,那将是一个幸福和好的。不幸的是,它总是空的,我必须设置一个单独的服务器来解决它:

server {
        server_name 127.0.0.1;
        location /group_1tv/ {
                if ($request_uri ~ "^/[^/]+(.*)") {}
                if ($http_node) {return http://$http_node$1;}
                proxy_cache hyvd;
                proxy_cache_valid any 1d;
                proxy_pass http://backend_group_1tv/;
        }
}

不幸的是,仅当$ http_node是非空的,并且返回400(未知位置),并且调试日志没有解释原因:

>
2014/02/02 18:31:15 [debug] 9602#0: *18 http upstream request: "/hds-live/livepkgr/_definst_/1tv.f4m?r=334"
2014/02/02 18:31:15 [debug] 9602#0: *18 http upstream process header
2014/02/02 18:31:15 [debug] 9602#0: *18 malloc: 09C12AD8:4096
2014/02/02 18:31:15 [debug] 9602#0: *18 recv: fd:12 137 of 4096
2014/02/02 18:31:15 [debug] 9602#0: *18 http proxy status 400 "400 Unknown location"

我已经花了整整2天的时间了,真的需要一个新的输入...

,所以我刚刚用内部代理解决了自己的400期,因为我将内容长度设置为无效设置('')而不是0。

删除此:proxy_set_header内容长度'';

最新更新