I've got a location block with an auth_request
like this
location /somepath {
auth_request /authorize;
auth_request_set $header_variable $upstream_http_custom_header;
proxy_path http://backendaddress;
}
What I want to do is, if the $header_variable
doesn't match a particular regex I want to return a 403 code.
if
isn't going to work because it runs too early. Is there anything else that would let me do this?
Nginx module auth_request waits for either 200 or 401/403 HTTP code from the backend:
Your request has a header that require to check for permission:
During auth request/response cycle your backend needs to check the header and return 403 code to prevent next request to happen without authentication. The module auth_request works as a simple test assert which returns one of the code. It does mean backend process that is responsible for this URL to reply http://backendaddress/authorize needs to have an additional check for required header.