一、nginx作为静态资源服务有三种配置方式:
location ~* (.+)\.(ico|gif|jpg|jpeg|png|html|htm|css|js|txt|json|xml|swf|wav|eot|svg|ttf|woff|exe)$ {
root D:/develop/nginx-1.13.12/static;
access_log off;
}
location ^~/wtxprint/ {
alias D:/develop/nginx-1.13.12/static/;
}
location ^~/wtxprint/ {
root D:/develop/nginx-1.13.12/static/;
}
1、第一种:所有指定后缀的资源访问都会被受理,
比如:
(1)static目录下有一个文件a.html,可以通过url问题:http://xxx:9999/a.html
(2)static/wtx目录下有一个文件a.html,可以通过url问题:http://xxx:9999/wtx/a.html
2、第二种:访问的url中包含/wtxprint/字符串的会被受理,
比如:
(1)static目录下有一个文件a.html,可以通过url问题:http://xxx:9999/wtxprint/a.html
(2)alias指令:/wtxprint/a.html--> D:/develop/nginx-1.13.12/static/a.html
3、第三种:访问的url中包含/wtxprint/字符串的会被受理,
比如:
(1)static/wtxprint目录下有一个文件a.html,可以通过url问题:http://xxx:9999/wtxprint/a.html
(2)root指令:/wtxprint/a.html --> D:/develop/nginx-1.13.12/static/wtxprint/a.html
二、gzip加速(待完善)