Mastering Nginx

(Ron) #1

A Configuration Guide


[ 36 ]

location @mongrel {
proxy_pass http://appserver;

}

Here, an implicit directory index is tried if the given URI is not found as a file, then
processing is passed on to appserver via a proxy. We will explore how best to use


location, try_files, and proxy_pass to solve specific problems throughout the
rest of the book.


Locations may be nested except when:



  • The prefix is "="

  • The location is a named location


Best practice dictates that regular expression locations be nested inside string-based
locations. An example of this is as follows:


# first, we enter through the root
location / {

# then we find a most-specific substring
# note that this is not a regular expression
location ^~ /css {

# here is the regular expression that then gets matched
location ~* /css/.*\.css$ {

}

}

}

The mail server section


The mail server section, or mail configuration context, is available only if you've


built NGINX with the mail module (--with-mail). This section controls all aspects


of working with the mail module.


The mail module allows for configuration directives that affect all aspects of
proxying mail connections, as well as for specifying them per server. The server


context also accepts the listen and server_name directives that we saw under


the http server section.

Free download pdf