nginx中只支持简单的if语句,不支持多条件判断和嵌套,通过特殊的方式也可以达到效果
location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; set $res 0; if ($arg_width ~ \d+){ set $res "${res}1"; } if ($arg_height ~ \d+){ set $res "${res}1"; } if ($res = "011"){ proxy_pass http://pe.cut; access_log /dev/null; } #if ($res != "011"){ # return http://xxx.xxx.xxx; #} }