#下面为location语法
规则:
location [=|~|~*|^~] /uri/ {
}
静态资源服务器
= 精准匹配
^~
~ 区分大小写的正则匹配
~* 不区分大小写的正则匹配
!~ 区分大小写不匹配
!~* 不区分大小写不匹配
/ 任何请求都会匹配到
location = / {
#规则 https://pcshao.cn/nginx-conf配置
}
location = /image{
#规则 匹配https://pcshao.cn/image
}
location ^~ /static/ {
#规则 https://pcshao.cn/static/a.html
}
location ~ \.(gif|jpg|png|js|css)$ {
#规则 https://pcshao.cn/logo.png
}
location ~* \.png$ {
#规则 https://pcshao.cn/logo.png 如果上面的规则存在则优先匹配上面的
#规则 https://pcshao.cn/logo.PNG 则匹配当前规则
}
Nginx分流转发服务器
location = / {
proxy_pass http://tomcat:8080/index
}