This is a full example for running an oauth2-proxy covered by a nginx as reverse proxy,
using the auth_request
parameter in combination with a required role to mach a location.
See oauth2-proxy/oauth2-proxy#1614 for discussion.
Suppose we have Location (A) that should allow access only to users having role roleA
location ^~ /roleAOnly/ {
auth_request /oauth2/auth/rolea;
error_page 401 = /oauth2/sign_in;