We are using nginx as a reverse proxy with the http_auth_request_module enabled. We would like to cache the requests to our authentication server in order to reduce the load of this server. This is the nginx configuration so far:
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;
}
}
The request is being accepted and the authentication works. But nothing is being written to the cache directory. Nginx has sufficient permissions to write to the cache directory:
drwxrwxrwx 2 nobody wheel 68B Jul 18 16:34 cache
How can I make the http_auth_request_module read from cache and make nginx write the response to cache?