If there were an OS option, I would have used it :)
[1] https://github.com/yaoweibin/nginx_http_oauth_module