May the URI specified with `auth_request` directive, reference capture groups (e.g. `$1`) from containing location?
J6DKLygdGq139TVZiBxq
nginx-forum at forum.nginx.org
Tue Mar 30 16:09:27 UTC 2021
Hi all,
I may be missing some crucial request processing knowledge, but I am trying
to issue an authentication request with variable URI, as as part of
processing a request for a protected resource. I hope I am able to express
below what I want:
```
location ~ /foo/(\d+)/bar {
auth_request /auth/$1/baz;
}
```
This does not seem to work, however -- `$1` above is interpreted literally
(it is not expanded), while what I want is for every request for /foo/1/bar
to only succeed after authorization request to /auth/1/baz, /foo/2/bar only
after authorization request to /auth/2/baz, and so on. Am I going wrong
about this? Crucially the authorization service has different URI patterns
than our website, so I can't just pass the entire URI and I cannot use one
single URI for all authorization requests.
What are my options here?
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,291109,291109#msg-291109
More information about the nginx
mailing list