location block
https://www.youtube.com/watch?v=3q2xxMc7XEo
Matching order
- = Exact match
- ^~ Preferential match
- ~ & *~ Regex match
- no mofier Prefix match
# Matches any prefix
# /greet
# /greeting
# /greet/something
location /greet {
return 200 'Hello from nginx prefix match location block';
}
# Exact match
location = /greet {
return 200 'Hello from nginx exact match location block';
}
# Regex match - case sensitive
# /greet123
location ~ /greet[0-9] {
return 200 'Hello from nginx case sensitive regex match location block';
}
# Regex match - case insensitive
#
location *~ /greet[0-9] {
return 200 'Hello from nginx case insensitive regex match location block';
}
# Prefix preferential match
# Same as location /greet, but more important than regex match
location ^~ /greet {
return 200 'Hello from nginx match with preferential over regex match location block';
}
반응형
'인프라 > nginx' 카테고리의 다른 글
Nginx - access log 파일 이름 (날짜 형태로 변경) (0) | 2022.05.09 |
---|---|
Nginx HTTP Server 1장 정리 (0) | 2021.11.17 |
긴급하게 적용 했던, rewrite/redirect 이야기 (0) | 2020.08.13 |