Status code in nginx try_files directive
- by Hamish
Is it possible to use the current status code as a parameter in try_files?
For example, we try to provide a host specific 503 static response, or a server-wide fallback if it wasn't found:
error_page 503 @error503;
location @error503 {
root /path_to_static_root/;
try_files /$host/503.html /503.html =503;
}
There are a number of these directives, so it would be convenient to do something like:
error_page 404 @error
error_page 500 @error
error_page 503 @error
location @error {
root /path_to_static_root/;
try_files /$host/$status.html /$status.html =$status;
}
But the Variables documentation doesn't list anything that we could use to do this.
Is it possible, or is there an alternative way to do this?