proxy_pass only if a file exists

mrtn nginx-forum at
Tue Apr 30 14:25:34 UTC 2013

I need to make sure a file actually exists before proxy_pass-ing the request
to an upstream server. I don't serve existing files directly using Nginx
because there are some application-specific logic i need to perform on the
application server for such requests.

I've looked at try_files, but it seems like it will serve the file
straightaway once it is found, which is not what I want here. Another way 
is to use if (!-f $request_filename), but as mentioned here:, it's not a terrible way
to check the existence of a file.

Is there a feasible yet efficient way?

Posted at Nginx Forum:,238747,238747#msg-238747

More information about the nginx mailing list