http core module是Ngnix提供WEB服务的最核心模块,默认被开启。本篇文章将讲述该模块的一些配置
web
配置文件结构:express
http { server {// virtual website location{ } } server{ location{ } } }
Location modifer 匹配规则
ide
匹配优先级与顺序: = --> No modifer --> ^~ modifier --> ~ or ~* modifier --> no modifier
spa
= 字符串精准匹配,不支持正则
orm
server {
server_name website.com;
location = /abcd {
[…]
}
}
server
http://website.com/abcd (exact match 精确匹配)
ci
http://website.com/ABCD (若是OS忽略大小写,则能够匹配)
字符串
http://website.com/abcd?param1¶m2(匹配,忽略query参数)
it
http://website.com/abcd/ (不匹配,多了一个slash斜杠)
io
http://website.com/abcde (不匹配)
No modifer :begin with the specifed pattern. You may not use regular expressions
server {
server_name website.com;
location /abcd {
[…]
}
}
http://website.com/abcd (exact match 精确匹配)
http://website.com/ABCD (若是OS忽略大小写,则能够匹配)
http://website.com/abcd?param1¶m2(匹配,忽略query参数)
http://website.com/abcd/ (匹配)
http://website.com/abcde (匹配)
The ~ modifer :case-sensitive 匹配正则
server {
server_name website.com;
location ~ ^/abcd$ {
[…]
}
}
http://website.com/abcd (exact match 精确匹配)
http://website.com/ABCD (不匹配)
http://website.com/abcd?param1¶m2(匹配,忽略query参数)
http://website.com/abcd/ (不匹配,多了一个斜杠)
http://website.com/abcde (不匹配)
The ~* modifer :case-insensitive 匹配正则
server {
server_name website.com;
location ~* ^/abcd$ {
[…]
}
}
http://website.com/abcd (exact match 精确匹配)
http://website.com/ABCD (匹配)
http://website.com/abcd?param1¶m2(匹配,忽略query参数)
http://website.com/abcd/ (不匹配,多了一个斜杠)
http://website.com/abcde (不匹配)
The ^~ modifer:if the pattern is matched, Nginx stops searching for other patterns
The @ modifer : 定义内部location块,能够经过内部跳转访问