To be more performant, we'd like to allow nginx to catch 404s before passing it off to the upstream apache server. Both servers have the same files.
We have a popular setup of serving static content on nginx and using apache upstream to serve dynamic content. We currently sync php along with static files to the nginx nodes from the upstream apache nodes. The same files are located on both layers. We simply serve only static files from nginx.
Currently, all non-static requests go upstream to the apache server (as previously intended). However, I realized nginx should be able to check for the existence of a .php file before deciding to pass it on upstream. That would mean handling a request much more efficiently.
I've been tinkering with a combination of try_files, then eventually if blocks to find a solution, but I haven't been successful. Please advise.