auth_request doesn't block return directive, can't return status?
From the nginx documentation, return
Stops processing and returns the specified code to a client.
Importantly, the "stops processing" does not occur at the point the directive is encountered, so the return always happens regardless of the subrequest's result.
The goal was simply to protect my /ping
endpoint and this tiny modification works: try_files
is of course subject to the auth_request
and since the path _
does not exist, it falls through when the auth_request
passes, but returns 401 or 403 if it does not:
location = /ping {
auth_request /validate;
try_files _ =204;
}