title: NGINX Lua Basic HTTP Authorization/Authentication Allow Certain Number of Attempts
body: <p>I'm trying to use a Lua script I found on this Git Repository: <a href="https://github.com/knq/nginx-crowd-lua/blob/master/crowd-auth.lua" rel="nofollow">https://github.com/knq/nginx-crowd-lua/blob/master/crowd-auth.lua</a> to authorize users to restricted content against an Atlassian Crowd user management system.</p>
  
  <p>What happens when I use this script as is is that if a user enters in an incorrect username/password, then the browser returns a 403 Forbidden response, without allowing the user to try again unless the user closes the browser and goes back to the page.</p>
  
  <p>What I'm trying to do is allow 3 attempts to log in before the 403 page is displayed.</p>
  
  <p>I've tried looping this script, but either the loop doesn't work, and an incorrect user/pass goes straight to the 403 page on the first attempt, or the loop is infinite, allowing unlimited attempts.</p>
  
  <p>Could someone please advise on this? If you need more detail please comment and I'll provide.</p>
  
  <p>Thanks</p>