Reputation: 85
Recently, I learning the nginx.I can't understand the following the routing configuration.Can anybody explain?Thanks!
root /home/ubuntu/demo/web_file;
location / {
root /home/ubuntu/demo/web_file/production;
index index.html index.htm;
}
location /vendors {
index index.html index.htm;
}
location /src {
index index.html index.htm;
}
location /build {
index index.html index.htm;
}
Upvotes: 1
Views: 51
Reputation: 49672
The value of the root
directive is inherited from the surrounding block, if it is not specified within the location
itself. See this document for details.
The location /
block is effectively the default location and matches any URI that does not match some other location
block.
In your configuration, you specify the root as /home/ubuntu/demo/web_file/production
for all URIs, except those that begin with /vendors
, /src
, or build
.
You do not need to repeat an identical index
statement in every location, as it is also inherited from the surrounding block, if it is not specified within the location
itself. See this document for details.
For example:
root /home/ubuntu/demo/web_file;
index index.html index.htm;
location / {
root /home/ubuntu/demo/web_file/production;
}
location /vendors {
}
location /src {
}
location /build {
}
Upvotes: 1