Root&alias File path Configuration
nginx Specify a file path there are two ways to root and alias, the use of this method is summarized, and it is convenient for everyone to respond quickly in the application process. The main difference between Root and alias is how Nginx interprets the URI after location, which causes the request to be mapped to the server file in different ways.
[Root]
Syntax: Root path
Default value: Root HTML
Configuration segments: HTTP, server, location, if
[Alias]
Syntax: Alias path
Configuration segment: Location
Instance:
Location ~ ^/weblogs/{
root/data/weblogs/www.jb51.net;
AutoIndex on;
Auth_basic "restricted";
Auth_basic_user_file passwd/weblogs;
}
If the URI of a request is/weblogs/httplogs/www.jb51.net-access.log, the Web server will return the/data/weblogs/www.jb51.net/weblogs/on the server Httplogs/www.jb51.net-access.log's file.
Root is mapped according to the full URI request, which is/path/uri. [
Therefore, the previous request is mapped to Path/weblogs/httplogs/www.jb51.net-access.log.
Location ^~/binapp/{
limit_conn limit 4;
Limit_rate 200k;
internal;
alias/data/statics/bin/apps/;
}
The alias discards the path configured behind the location and points the directory that is currently matched to the specified directory. If the URI of a request is/binapp/a.jb51.net/favicon, the Web server will return the/DATA/STATICS/BIN/APPS/A.JB51.NET/FAVICON.JGP file on the server.
1. When using alias, you must add "/" after the directory name.
2. Alias can specify any name.
3. Alias when using a regular match, you must capture what you want to match and use it at the specified content.
4. The alias can only be located in a location block.
Index directory Configuration
to simply share files, some people use SVN, some use FTP, but more people use the index function. Apache has a powerful index, and is also the most common, nginx auto_index to achieve a small directory index, and the function is very simple. Let's take a look at our effect chart first.
Nginx Configuration
Location ~ ^/2589 (/.*)
{
autoindex on;//Open
autoindex_localtime on;//turn on display features
}