Chinaunix

标题: nginx下可否实现对某个目录的访问限制 [打印本页]

作者: 剑心通明    时间: 2008-07-11 10:56
标题: nginx下可否实现对某个目录的访问限制
apache下很容易实现,nginx刚测试了一下,不是太熟悉,想实现某个目录只允许某些ip、ip段访问,应该怎么做?
作者: tecer    时间: 2008-07-11 16:40
提示: 作者被禁止或删除 内容自动屏蔽
作者: scyzxp    时间: 2008-07-11 17:25
原帖由 剑心通明 于 2008-7-11 10:56 发表
apache下很容易实现,nginx刚测试了一下,不是太熟悉,想实现某个目录只允许某些ip、ip段访问,应该怎么做?

这个更容易实现
www.nginx.net
作者: 剑心通明    时间: 2008-07-12 10:48
ngx_http_access_module
This module provides a simple host-based access control.

Module ngx_http_access_module makes it possible to control access for specific IP-addresses of clients. Rules are checked in the order of their record to the first match.

Example configuration

location / {
    deny    192.168.1.1;
    allow   192.168.1.0/24;
    allow   10.1.1.0/16;
    deny    all;
}
In the above example access is only granted to networks 10.1.1.0/16 and 192.168.1.0/24 with the exception of the address 192.168.1.1.

When implementing many rules, it is generally better to use the ngx_http_geo_module.
作者: 剑心通明    时间: 2008-07-12 10:49
很奇怪的是,我按这个加了也不管用
作者: 剑心通明    时间: 2008-07-12 10:50
ports安装nginx的,把所有http开头的模块都装了,但是nginx -V却没有ngx_http_access_module
作者: litiger    时间: 2008-07-13 17:33
最近怎么都开始研究nginx了?呵呵!配置文件还很不熟悉,没apache用着顺手!
作者: tecer    时间: 2008-07-13 18:38
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2