设置变量
server-> set $variable value;keepalived + nginx 高可用
location 匹配符 匹配规则 优先级
= 精确匹配 1
^~ 以某个字符串开头 2
~ 区分大小写的正则匹配 3
~* 不区分大小写的正则匹配 4
!~ 区分大小写的不匹配的正则 5
!~* 不区分大小写的不匹配的正则 6
/ 通用匹配,任何请求都会匹配到 7
map
http {
map $http_cookie $target_dir {
"~*version=gray(;|$)" "/gray";
"~*version=stable(;|$)" "/stable";
default "/stable";
}
server {
location / {
root html$target_dir;
try_files $uri $uri/ /index.html;
}
}
}日志切割
open_log_file_cache max=100;
map $time_iso8601 $logdate {
'~^(?<ymd>\d{4}-\d{2}-\d{2})' $ymd;
default 'date-not-found';
}
access_log logs/access-$logdate.log ;