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;    
                #}
    }

 

相关文章:

  • 2021-11-20
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2022-01-28
  • 2021-08-15
  • 2022-12-23
  • 2022-01-19
  • 2021-11-08
  • 2022-01-21
  • 2022-12-23
相关资源
相似解决方案