Directives:
matches the specified request URI
syntax:
LOCATION [= | ~ | ~ * | ^ ~ | @] / URI / {Configuration}
Match command:
~ for performing a regular matched case-sensitive
~ * denotes perform a regular match case-insensitive
^ ~ represent ordinary characters to match, if the option match, only match this option does not match the other. General catalog to match
= exact match for normal characters
without a prefix string for normal
@ define a named LOCATION, used in the internal orientation, e.g. error_page, try_files
# string matching are two types: normal string, the regular expression formula.
# ~ * ~ And for regular expressions, without any other prefix and prefix are used for ordinary strings.
# Regular expression matching will be based on the order to match the first regular expression after stop searching.
# Ordinary string match is to ignore the order, will choose the most accurate match.
Priority:
1, first matching ordinary string, the closest match is temporarily stored;
2, then the regular expression matching in declaration order in the configuration file, if it matches a regular expression, then stopped matching, taking the regular expression formula matching result;
3, if all the regular expression match is not on, the result of a taken;
4, if an ordinary character string and a regular expression match is not on, the packet 404 nOT FOUND.
Common configuration commands: alias, root, proxy_pass
. 1, alias
alias configuration, to access the file system, after a match to the URI, the path to the alias configuration, such as:
LOCATION / Test / {
alias / usr / local /;
}
# request / test / file, return to files in / usr / local / file
regular location expression in alias, will use regular expression value
location ~ * / Test / (+ \ (GIF | PNG | JPEG) {..
Alias / usr / local / test1 / $. 1;
}
eg: /test/love.gif into /usr/local/test1/love.gif
2, root
root path for accessing the file system, after a match to the URI, the path to the root configuration, and is attached to the request path Thereafter, as:
LOCATION / Test / {
root / usr / local /;
}
# request / test / file, will return to the file / usr / local / test / file .
3, proxy_pass
agent configuration requests to the proxy, to match the URI, URL proxy_pass configured to forward the request.
location / Test / {
proxy_pass http://192.168.1.111:8089/;
}
EG: / Test / Hello transformed into http://192.168.1.111:8089/hello
# If configured proxy_pass "/" no additional location of URI,
not configured "/" will be appended.