There are many ways to do this with Lua, https://www.google.nl/#q=nginx+lua+authentication Even via a database, https://github.com/openresty/lua-resty-mysql Posted at Nginx Forum: https://forum.nginx.org/read.php?2,262394,262396#msg-262396