1, "Alias"--alias configuration, used to access the file system, after matching the URL path to the location configuration, point to the path of "alias" configuration. Such as:
location/test/
{
alias/first/second/img/;
}
That is: Request/test/1.jpg (omitting the protocol and domain name), the file/first/second/img/1.jpg will be returned.
2, "root"--root path configuration, used to access the file system, after matching to the location configuration URL path, point to the "root" configuration path, and attach the location configuration path thereafter. Such as:
location/test/
{
root/first/second/img/;
}
That is: Request/test/1.jpg (omit the protocol and domain name), will return the file/first/second/img/test/1.jpg, compared to alias, using root will append/test/to the root directory.
3, "Proxy_pass"-Reverse proxy configuration, for proxy requests, for the front-end load separation or multiple machines, server load separation scenario, after matching to the location configuration URL path, forwarding the request to the "Proxy_pass" configured URL, Whether the location configuration path will be appended with "/" after the path configured by "Proxy_pass", with "/" is not attached, such as:
location/test/
{
proxy_pass http://127.0.0.1:8080/;
}
That is: Request/test/1.jpg (omit the protocol and domain name), will be the Nginx forwarding request to Http://127.0.0.1:8080/1.jpg (/test/path is not attached).
location/test/
{
proxy_pass http://127.0.0.1:8080;
}
That is: Request/test/1.jpg (omit the protocol and domain name), will be the Nginx forwarding request to http://127.0.0.1:8080/test/1.jpg (additional/test/path).
location/test/
{
proxy_pass http://127.0.0.1:8080/img;
}
That is: Request/test/1.jpg (omit the protocol and domain name), will be the Nginx forwarding request to Http://127.0.0.1:8080/img1.jpg (/test/path is not attached, but the path after the addition of/test/).