码迷,mamicode.com
首页 > Web开发 > 详细

Nginx笔记:对url中携带的参数进行多次判断

时间:2018-01-18 14:59:31      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:res   idt   xxx   语句   http   col   bsp   if语句   pass   

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

 

Nginx笔记:对url中携带的参数进行多次判断

标签:res   idt   xxx   语句   http   col   bsp   if语句   pass   

原文地址:https://www.cnblogs.com/djoker/p/8310024.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!