I'm trying to integrate custom authentication logic into my Nginx server. I need to validate users against an internal API before granting access. Has anyone done something similar? Any configuration snippets or best practices would be greatly appreciated.