I'm trying to set up nginx redirects using a technique very similar to the method discussed in this question.
I also set a default using the following code:
map $arg_request_id $url_prefix{
default /old;
include /a/b/c/redirect_urls.map;
}
The default is a fallback which I want to go to when anything goes wrong. The redirect_urls.map file is updated regularly. Now, the issue I have is that there are cases where something goes wrong and the redirect_urls.map file gets deleted (or it's a new machine which does not have a redirect_urls.map file yet). The problem I face is that when I run
>>> nginx -s reload
nginx: [emerg] open() "/a/b/c/d/redirect_urls.map" failed (2: No such file or directory) in /etc/nginx/nginx.conf:22
How can I make it such that if the file does not exist then nginx simply picks up the default value, and simply always set $url_prefix to /old instead of giving a file not found error? Would try_files help in this case?