How can I serve one file in the location directive?

How to return one file to the location directive without any backups? Try_files requires at least two. It seems simple, but I cannot find it in documents or examples.

location / { try_files one_file; # => wrong number of parameters } 
+7
nginx
source share
1 answer

The easiest way is to use the option of redirecting to an error code if the file does not exist.

 location / { try_files /theOnlyFile.html =404; } 
+10
source share

All Articles