Welcome! Log In Create A New Profile

Advanced

Caching auth_request!

April 29, 2021 02:50PM
Hello,

I am caching the result of auth_request. This is the simplified code:
proxy_cache_path /var/cache/nginx levels=1 keys_zone=token_cache:1m max_size=2m
inactive=60m use_temp_path=off;

location /devices {
auth_request /auth;
auth_request_set $token $upstream_http_x_token;
proxy_set_header Authorization $token;
set $endpoint https://upstream;
proxy_pass $endpoint;

}

location = /auth {
proxy_cache token_cache;
proxy_cache_valid any 30m;
proxy_cache_key "$request_uri";
set $endpoint http://127.0.0.1:6001;
proxy_pass http://auth_server;
}

I can see that my requests are being cached
when I do: curl https://10.0.2.6:443/devices
however, caching is useless because the auth server is requested every time.

What is really strange is that when I curl the auth server directly, it behaves as expected:
curl https://10.0.2.6:443/auth
Then the auth_server is hit only after the cache expires

Has anyone experienced the same issue?
Subject Author Posted

Caching auth_request!

bouvierh April 29, 2021 02:50PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 269
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready