February 2018
Beginner to intermediate
348 pages
9h 40m
English
Context: server, location. Variables are accepted.
Attempts to serve the specified files (arguments 1 to N-1); if none of these files exist, it jumps to the respective named location block (last argument) or serves the specified URI.
Syntax: Multiple file paths, followed by a named location block or a URI
Example:
location / {
try_files $uri $uri.html $uri.xml @proxy;
}
# the following is a "named location block"
location @proxy {
proxy_pass 127.0.0.1:8080;
}
In this example, Nginx tries to serve files normally. If the request URI does not correspond to any existing file, Nginx appends .html to the URI and tries to serve the file again. If it still fails, it tries with .xml. Eventually, if all of these possibilities fail, another ...
Read now
Unlock full access