我有一个重写规则如下:
if ( $request_uri ~ https://subdomain.domain.com/abc/xyzdirector/login.do ) {
return 444;
}
现在这工作正常,但是,我想对这个规则有一个例外。我想让IP ABCD 通过,即这个IP 不应该受这个规则的约束。如何做到这一点?
http://wiki.nginx.org/HttpCoreModule#Variables包括以下内容:
$remote_addr
The address of the client.
$binary_remote_addr
The address of the client in binary form;
笔记:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#if指示 if 语句的允许上下文作为服务器和位置
换句话说,你不能嵌套 if 语句,所以你会得到如下内容:
location /abc/xyzdirector/login.do {
if ( $remote_addr != <allowed adress> ) { return 444;}
#if you get here it was an allowed adress so add config to server the request.
}