NGINX - parse request body to get the correct file
nginx isn't designed to perform application logic like this.
You need to use either the Lua module or the njs module to implement logic like this.
Another approach is to implement the backend logic in application (PHP, Python, Ruby, Perl etc.), and then the application would return response with X-Accel-Redirect header to tell what file nginx should send.