Problems with nginx caching setup

I have setup a demo system using 2.11 with the Sierra Leone database. The system is running on an AWS instance, Ubuntu 12.04, Postgres, Tomcat7.

I am getting some strange behavior with user sessions interfering with each other when nginx caching is enabled. Sometimes, it works, sometimes it gives weird behavior like when logging out, the login page looks like the screen shot below, other times, the user cannot logout at all, and is simply redirected to the dashboard.

I have followed the setup in the implementers manual quite closely, and on another system with almost the exact same setup, I do not get these issues. Any clues what might be causing this?