<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;"><div><div><div><span style="font-family: Arial; font-size: medium; background-color: rgb(255, 255, 255);">Hi All,</span><br style="clear: both; font-family: Arial; font-size: medium;"><br style="clear: both; font-family: Arial; font-size: medium;"><span style="font-family: Arial; font-size: medium; background-color: rgb(255, 255, 255);">We're starting to make more and more heavy use of Nginx having shifted from Apache, mostly in handing off to backends running Puma and php-fpm. However, wherever possible we naturally want Nginx to serve what it can with only the bare minimum hitting the back end. However, this generally means writing more and more complex rules.</span><br style="clear: both; font-family: Arial; font-size: medium;"><br style="clear: both; font-family: Arial; font-size: medium;"><span style="font-family: Arial; font-size: medium; background-color: rgb(255, 255, 255);">I have a requirement for Nginx to serve a file if it exists or hand off to a Rails controller. The URI is data?x=X&y=Y&z=Z which at the moment goes direct to a Rails controller, sends the file back directly and saves a static png file in the process. What I need to do in Nginx is take the parameters of the URI and check whether the file /data/X_Y_Z.png exists. If not hand off to the Rails controller. This means that Nginx serves files and only hands off to Rails when needed. It also means that I need to formulate the file that I want to check from the get parameters ($args_parameter?) in the Nginx config.</span><br style="clear: both; font-family: Arial; font-size: medium;"><br style="clear: both; font-family: Arial; font-size: medium;"><span style="font-family: Arial; font-size: medium; background-color: rgb(255, 255, 255);">I've been trying various things out through try_files which I think is the right area to be looking at. Something like:</span><br style="clear: both; font-family: Arial; font-size: medium;"><br style="clear: both; font-family: Arial; font-size: medium;"><span style="font-family: Arial; font-size: medium; background-color: rgb(255, 255, 255);">try_files /tiles/$args_z_$args_x_$args_y.png proxy_hand_off</span><br style="clear: both; font-family: Arial; font-size: medium;"><br style="clear: both; font-family: Arial; font-size: medium;"><span style="font-family: Arial; font-size: medium; background-color: rgb(255, 255, 255);">Any ideas how I could do this? Anything would be appreciated including an easier way I haven't thought of. I naturally want to keep 'if' statements down to a minimum, if any at all.</span></div></div></div></body></html>