This is what I'd like to achieve:
I want to use nginx as a classic reverse proxy to expose server's resources. Before calling the server, nginx should ask a token to the token issuer (an internal service) and inject this token into the authentication header of the call towards the server.
Is it possibile to achieve this with nginx?
I looked around inside the nginx documentation and I know I can use proxy_set_header to modify the headers being proxied to the server.
Update
I was able to make the solution below work; here is a POC on github

auth_request_setdirective.