I need to improve this configuration: https://docs.docker.com/registry/recipes/nginx/
So that authentication would happen using subrequest to service, which is returning json.
Perhaps I need to use lua. Need to analyze json answer and return authentication error or proxy_pass to one of upstream docker-registries, which are choosed upon flag in json, returned by auth service.
So I need not only make auth subrequest, as shown here: https://www.nginx.com/resources/admin-guide/restricting-access-auth-request/
But also set proxy_pass according value in json, returned as result of successful auth request.
Is it possible? Is there some nginx+lua example or tutorial, which is doing something similar?
Any hints will be appreciated.
Thank you!