Sorry I dont quite understand whats going on in your config.
error_page 418 @auth-cache;
if ($logged_in) {
return 418;
what does this do? looked up http error 418 "I'm a teapot" ROFL. so
going line by line
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,220510,220524#msg-220524