I am trying to optimize my Nginx config but ran into an issue I don't know how to fix. I have a folder /images
on my server from which I deliver various static files for a website. The same folder though is also used in order to upload files via WebDAV.
Therefore, I have have to check for every request is the static file exists AND if the request method is GET
, I deliver the file. Otherwise, I assume that the request was related to WebDAV (such as PUT, etc). See this sample:
if ($uri ~* ^/images) { set $getimages "${getimages}A"; }
if ($request_method = GET) { set $getimages "${getimages}B"; }
if ($getimages = "AB") {
rewrite ^ $uri$args last;
}
This above sample works fine. But I was wondering if there's another way to do this, without using IF. Given the IfIsEvil reference in the Nginx Wiki
Ideas anyone?