达到以下效果:
1,特定目录被指定IP访问
2,不是指定的IP地址不能执行URI中特定字符串
3,特定目录中不能执行PHP文件
set $self_visit '';if ( $request_uri ~* "XXFILE" ) {set $self_visit "${self_visit}Y";}if ( $http_x_forwarded_for !~* ^11\.22\.33\.44.* ) {set $self_visit "${self_visit}Y";}if ( $self_visit = YY ) {return 400;}location ~ /self/ {root /phpxx/;index index.php;allow 11.22.44.44; deny all;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME phpxx$fastcgi_script_name;include fastcgi_params;}location ~ /yoursle/.*\.(php|php5)(.*)$ {deny all;}