S
S
Softer2018-10-19 11:20:00
Nginx
Softer, 2018-10-19 11:20:00

How to make synchronous subrequests in Nginx + NJS?

Good day.
There is Nginx, it already has some simple njs scripts. There is a task to check the token (from the headers) on a third-party service and the desire to do it on the same njs (it has off-line support, and I don’t want to put something else, especially third-party). The essence of the check is simple - if the token is not valid - 403, otherwise - proxy_pass.
But the catch is that the subrequest is executed asynchronously and the result of its request as the result of the work of the entire function cannot be used. Has anyone faced a similar issue?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2018-10-19
@Softer

To do this, nginx has the auth_request directive

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question