nginx_location

Nginx location configuration syntax
     . 1 . LOCATION [= | ~ | ~ * | ^ ~ ] URI {...}
     2 . {...} LOCATION the @name     
LOCATION configuration can have two possible configurations 
1. prefix + uri (string / regular expression)
 2 . @ + name 
prefix meaning
     =   : an exact match ( must be all equal )
     ~   : case sensitive
     ~ * : ignore case
     ^ ~ : simply match the uri section 
@: internal services Jump
uri: uniform resource identifier (English: uniform resource identifier, abbreviated: URI ) string in computer terms is a name that identifies a particular Internet resources in
the most common form of URI is the uniform resource locator (URL), often designated as informal URL


Location basics
1 .location is configured in the server block.

2You may be used in different configurations (location configuration) Depending on the URI, to handle different requests.
URL: Uniform Resource Locator System (Uniform Resource Locator; the URL ) is a representation of the information for specifying the location on the Internet web service program

. 3 .location is in order, will be the first location matching process.
Location Configuration Demo

. 1 . = , Matches exactly LOCATION = / {#} Rule
# matched to the HTTP `:
// www.example.com /` such a request.

2 ~ , case sensitive LOCATION ~ / Example / {#} Rule
# sample request #http:
// www.example.com/Example/ [Success]
#http: // www.example.com/example/ [Failed ]

3 ~ * , ignore case LOCATION ~ * / Example / {#} rule
# is ignored case portion #http uri:
//www.example.com/Example/ [Success]
#http: // www.example.com/example/ [Success]

4 . ^ ~ , beginning only matches uri LOCATION ^ ~ / IMG / {rules} #
# in
/ img / requests beginning, #http the match will be: // www.example.com/img/a.jpg [success]
#http: // www.example.com/img/b.mp4 [success]

5 @. internal nginx jump LOCATION / img / {error_page 404 @img_err; @img_err LOCATION} {#} rule
# to
request / img / beginning, if the link status is 404 . It will be matched to the @img_err this rule.

 

Guess you like

Origin www.cnblogs.com/betterquan/p/11846632.html