I'm trying to implement an auth_request call for an upstream host that is not guaranteed to be running.
My understanding is that, when calling proxy_pass, using set $foo some.service for an upstream host is the proper way to prevent nginx from throwing an error at boot, and properly resolving the IP address.
In isolation this pattern works fine:
location /happy/ {
set $a_endpoint http://my_service/;
proxy_pass $a_endpoint;
}
The above allows $a_endpoint to:
- Not require the upstream host to be running when nginx starts
- Dynamically update the IP address for the associated
my_service.
I've tried to pair this with an auth_request and I see failing results
location /protected/ {
auth_request /oauth2/auth;
error_page 401 = /oauth2/sign_in;
set $a_endpoint http://my_service/;
proxy_pass $a_endpoint;
}
This first results is a 202 from the oauth API.
The second result is a 404 from the oauth API.
The second call is in fact being proxy_passed to the URL defined in auth_request? why...
I've verified that the second call is going to oauth instead of my_service in both debug nginx logs and wireshark.
Why is the second call being sent to the service defined in oauth2 instead of my_service?