nginx根据ip来源分流

  sre


在server层做:

server {
    ...
    if(remote_addr !~ ^119\.139 ){
        rewrite ^/(.*) https://baidu.com;
    }

    location / {
        ...
    }
}

在location层做:

    location /{
        if(remote_addr !~ ^119\.139 ){
            rewrite ^/(.*) https://baidu.com;
        }
        proxy_pass http://my_upstream;
    }

LEAVE A COMMENT

Captcha Code