nginx access to server static resources based on specific paths
A recent requirement is that the URL specify a path to access the server's static resources. The simple configuration always reports 404 errors. Description is that Nginx cannot find the resources you have configured. There are two kinds of static resource allocation methods common to nginx agent. One is to specify the file type.
Location ~/(javascript|css|images) {
root/users/web;
}
The other is to specify the file path, which we set.
Location ^~/ma/{
root/users/web;
}
~ starts with a case-sensitive regular match, ^ non, = the beginning represents an exact match, and not all of this is explained here.
Our configuration is as follows: Place our resource files under/var/deploy/fpos_mobile/fpos/. The goal is to access the server static resources directly when we access the http://shop.fpsit.trendy-global.com/MA/. However, it has not been accessible.
It was not until we saw the alias that the root path configuration problem occurred.
Location ^~/ma/{
alias/users/web;
}
When I have the same browser access/ma/index.html use root to map to/users/web/ma/index.html
Using alias maps directly to/user/web/index.html This is why resources are not found. So, depending on our resource location, you can access it by simply changing the root to alias.