I'm wondering why don't you try http://wiki.nginx.org/HttpRefererModule? Posted at Nginx Forum: http://forum.nginx.org/read.php?2,214166,214255#msg-214255