nginx限制ip访问 nginx访问权限
2012-05-09 17:38
148 查看
一、服务器全局限IP
#vi nginx.conf
allow 10.57.22.172;
deny all;
二、站点限IP
#vi vhosts.conf
站点全局限IP:
location / {
index index.html index.htm index.php;
allow 10.57.22.172;
deny all;
location ~ \.php$ {
if ( $fastcgi_script_name ~ \..*\/.*php ) {return 403;}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/htdocs$fastcgi_script_name;
include fastcgi_params;
}
}
站点IP限目录:
location / {
index index.html index.htm index.php;
}
location ^~ /test/ {
allow 10.57.22.172;
deny all;
if ( $fastcgi_script_name ~ \..*\/.*php ) {return 403;}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/htdocs$fastcgi_script_name;
include fastcgi_params;
}
location ~ \.php$ {
if ( $fastcgi_script_name ~ \..*\/.*php ) {return 403;}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/htdocs$fastcgi_script_name;
include fastcgi_params;
}
注意事项:
1. deny 一定要加一个ip,否则直接跳转到403,不往下执行了;如果403默认页是同一域名下,会造成死循环访问;
2. allow的ip段
从允许访问的段位从小到大排列,如127.0.0.0/24 下面才能是10.10.0.0/16
24表示子网掩码:255.255.255.0
16表示子网掩码:255.255.0.0
8表示子网掩码:255.0.0.0
3. deny all;结尾 表示除了上面allow的其他都禁止
如:
deny 192.168.1.1;
allow 127.0.0.0/24;
allo w 192.168.0.0/16;
allow 10.10.0.0/16;
deny all;
本文出自 “网事” 博客,请务必保留此出处http://gxjluck.blog.51cto.com/1211751/858928
#vi nginx.conf
allow 10.57.22.172;
deny all;
二、站点限IP
#vi vhosts.conf
站点全局限IP:
location / {
index index.html index.htm index.php;
allow 10.57.22.172;
deny all;
location ~ \.php$ {
if ( $fastcgi_script_name ~ \..*\/.*php ) {return 403;}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/htdocs$fastcgi_script_name;
include fastcgi_params;
}
}
站点IP限目录:
location / {
index index.html index.htm index.php;
}
location ^~ /test/ {
allow 10.57.22.172;
deny all;
if ( $fastcgi_script_name ~ \..*\/.*php ) {return 403;}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/htdocs$fastcgi_script_name;
include fastcgi_params;
}
location ~ \.php$ {
if ( $fastcgi_script_name ~ \..*\/.*php ) {return 403;}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/htdocs$fastcgi_script_name;
include fastcgi_params;
}
注意事项:
1. deny 一定要加一个ip,否则直接跳转到403,不往下执行了;如果403默认页是同一域名下,会造成死循环访问;
2. allow的ip段
从允许访问的段位从小到大排列,如127.0.0.0/24 下面才能是10.10.0.0/16
24表示子网掩码:255.255.255.0
16表示子网掩码:255.255.0.0
8表示子网掩码:255.0.0.0
3. deny all;结尾 表示除了上面allow的其他都禁止
如:
deny 192.168.1.1;
allow 127.0.0.0/24;
allo w 192.168.0.0/16;
allow 10.10.0.0/16;
deny all;
本文出自 “网事” 博客,请务必保留此出处http://gxjluck.blog.51cto.com/1211751/858928
相关文章推荐
- nginx中设置限制指定用户或IP组访问权限
- nginx限制ip访问权限
- Nginx Apache Iptable 限制ip并发访问 限制ip连接数
- nginx添加ip访问频率限制
- nginx限制某个IP同一时间段的访问次数
- nginx 限制ip/限制访问路径
- 为nginx添加ip访问频率限制
- nginx限制某个IP同一时间段的访问次数
- 4000 基于IP配置Nginx的访问权限-
- nginx限制某个IP同一时间段的访问次数
- Nginx中如何限制某个IP同一时间段的访问次数
- nginx中如何限制某个IP同一时间段的访问次数
- Nginx 使用IP限制访问来源
- nginx限制某个IP同一时间段的访问次数
- 权限系统 - 用户访问安全之IP限制 推荐
- Nginx在CDN加速之后,获取用户真实IP做并发访问限制的方法
- Nginx限制某一段时间内同一ip访问数及并发连接数配置
- nginx针对某个url限制ip访问,常用于后台访问限制
- nginx-----nginx针对某个url限制ip访问,常用于后台访问限制
- nginx apache限制ip并发访问 限制ip连接