码迷,mamicode.com
首页 > 其他好文 > 详细

NGINX配置小随笔

时间:2015-01-06 13:22:46      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

达到以下效果:

 

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

 

NGINX配置小随笔

标签:

原文地址:http://www.cnblogs.com/aguncn/p/4205725.html

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