1,在php.conf中增加重写规则
location /hello/ {
root
index
fastcgi_pass
include fastcgi.conf
rewrite ^/hello/(.*?) /world/&1 break;
}
2,添加ip配置文件
vim user_ip_hello.conf
127.0.0.1 1;
123.45.67.89
3,配置ip白名单策略文件
vim user_ip_policy.conf
set $ip_hello_denied 0;
if( $request_url ~ "^/hello/" )
{
set $ip_hello_denied 1;
}
if( $hit_hello_whitelist = 1)
{
set $ip_hello_denied 0;
}
if( $ip_hello_denied = 1)
{
return 403;
}
4, 把ip白名单与url规则映射起来
vim php.conf
map_hash_max_size 10240;
map $remote_addr $hit_hello_whitelist
{
default 0;
include user_ip_hello.conf
}
5,重启nginx吧。