linux-nginx常用骚操作

nginx if else 实现

set $is_matched 0; if ($http_user_agent ~* "wget") { set $is_matched "${is_matched}1"; } if ($remote_addr ~ "127.0.0.1|172.16.11.10") { set $is_matched "${is_matched}01"; } # 满足条件: # 当 http_user_agent == wget or remote_addr = ip # is_matched 值为 01 001 # 当条件为 http_user_agent == wget and remote_addr = ip # is_matched 值为 0101 if ($is_matched = "01"){ return 403; }