Welcome! Log In Create A New Profile

Advanced

May the URI specified with `auth_request` directive, reference capture groups (e.g. `$1`) from containing location?

March 30, 2021 12:09PM
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?
Subject Author Posted

May the URI specified with `auth_request` directive, reference capture groups (e.g. `$1`) from containing location?

J6DKLygdGq139TVZiBxq March 30, 2021 12:09PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 54
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready