我正在尝试以这种方式使用nginx
's ngx_http_auth_request_module
:
server {
location / {
auth_request http://external.url;
proxy_pass http://protected.resource;
}
}
Run Code Online (Sandbox Code Playgroud)
它不起作用,错误是:
2017/02/21 02:45:36 [error] 17917#0: *17 open() "/usr/local/htmlhttp://external.url" failed (2: No such file or directory), ...
Run Code Online (Sandbox Code Playgroud)
或以这种方式与named location
:
server {
location / {
auth_request @auth;
proxy_pass http://protected.resource;
}
location @auth {
proxy_pass http://external.url;
}
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,错误几乎相同:
2017/02/22 03:13:25 [error] 25476#0: *34 open() "/usr/local/html@auth" failed (2: No such file or directory), client: 127.0.0.1, server: , request: "GET / HTTP/1.1", subrequest: "@auth", host: "127.0.0.1" …
Run Code Online (Sandbox Code Playgroud) nginx ×1