what is the @ representing in the below code ?
location @default {
# ...
}
location /somewhere {
try_files $uri @default;
}
what is the @ representing in the below code ?
location @default {
# ...
}
location /somewhere {
try_files $uri @default;
}
for the above question :
location @default {
# ...
}
location /somewhere {
try_files $uri @default;
}
If the incoming request is received at http://your-domain/somewhere, then the location matches /somewhere and it tries in two places sequentially to find a response, as specified by the try_files directive, responding with the first successful try.
location @default
directive. A named_location will never match an incoming request, and is used by reference to specify the response in other location directives.In this way, an if statement can be avoided (if the file exists, then use it, else respond as spec’d in the location @default directive). So it can be used as a shorthand for an if condition. “If” statements are definitely “frowned upon” by the nginx authors (if is evil) as they have some limitations and may not give the expected result.
Nginx Docs Ref: Module ngx_http_core_module