缓存 auth_request 模块的结果

Tho*_*mas 7 caching nginx http-caching

我们使用 nginx 作为反向代理并启用了http_auth_request_module。我们希望将请求缓存到我们的身份验证服务器以减少该服务器的负载。这是到目前为止的 nginx 配置:

server {
  ...
  location /sso {
    auth_request /identity;
    proxy_pass http://localhost:8081;
  }

  location /identity {
    internal;
    proxy_pass              http://localhost:8081;
    proxy_cache_path        /opt/nginx/cache levels=1:2 keys=authentication:1m;
    proxy_cache             authentication;
    proxy_cache_key         $cookie_authentication;
    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 有足够的权限写入缓存目录:

drwxrwxrwx   2 nobody  wheel    68B Jul 18 16:34 cache
Run Code Online (Sandbox Code Playgroud)

如何使 http_auth_request_module 从缓存中读取并使 nginx 将响应写入缓存?