我想使用多个auth_request指令来尝试与多个服务器进行身份验证-即,如果第一个身份验证服务器返回403,请尝试第二个身份验证服务器。我尝试了一个像这样的简单方法:
location /api {
satisfy any;
auth_request /auth-1/;
auth_request /auth-2/;
proxy_pass http://api_impl;
}
location /auth-1/ {
internal;
proxy_pass http://auth_server_1;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
location /auth-2/ {
internal;
proxy_pass http://auth_server_2;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
Run Code Online (Sandbox Code Playgroud)
但是nginx不会解析配置文件。我收到了回复
nginx: [emerg] "auth_request" directive is duplicate
Run Code Online (Sandbox Code Playgroud)
有没有办法在Nginx中实现这种功能?