# Restrict access problem

**URL:** <https://www.ruby-forum.com/t/restrict-access-problem/148724>\
**Category:** NGINX\
**Created:** [September 16, 2008, 5:12pm UTC](https://www.ruby-forum.com/t/restrict-access-problem/148724 "2008-09-16T17:12:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lhmwzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90db22/32.png) [@lhmwzy](https://www.ruby-forum.com/u/lhmwzy)\
**Post date:** [September 16, 2008, 5:12pm UTC](https://www.ruby-forum.com/t/restrict-access-problem/148724/1 "2008-09-16T17:12:55Z")

</div>

I want to do a restrict access for URI contains xinxi,I do as follow:

```
location ~ xinxi {
            allow 10.68.49.21;
            auth_basic "need authried";
            auth_basic_user_file passwd;
            deny all;
    }

```

when I access [http://10.66.23.102/bxzx/xinxi/](http://10.66.23.102/bxzx/xinxi/) from 10.68.49.210,nginx  
says “403 Forbidden”.  
I think the rule checkorder is  
first “allow 10.68.49.21;”  
then " auth\_basic “need authried”;auth\_basic\_user\_file passwd;"  
last “deny all”  
So when I access [http://10.66.23.102/bxzx/xinxi/](http://10.66.23.102/bxzx/xinxi/) from  
10.68.49.210,nginx should prompt me to input username and password.  
Am I right?

---

<div class="post-metadata">

**Author:** ![lhmwzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90db22/32.png) [@lhmwzy](https://www.ruby-forum.com/u/lhmwzy)\
**Post date:** [September 16, 2008, 5:17pm UTC](https://www.ruby-forum.com/t/restrict-access-problem/148724/2 "2008-09-16T17:17:05Z")

</div>

2008/9/16 lhmwzy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> says “403 Forbidden”.  
> I think the rule checkorder is  
> first “allow 10.68.49.21;”  
> then " auth\_basic “need authried”;auth\_basic\_user\_file passwd;"  
> last “deny all”  
> So when I access [http://10.66.23.102/bxzx/xinxi/](http://10.66.23.102/bxzx/xinxi/) from  
> 10.68.49.210,nginx should prompt me to input username and password.  
> Am I right?

Also I know the config  
location ~ xinxi {  
satisfy any;  
allow 10.68.49.21;  
auth\_basic “need authried”;  
auth\_basic\_user\_file passwd;  
deny all;  
}  
can do the job well.

---

<div class="post-metadata">

**Author:** ![lhmwzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90db22/32.png) [@lhmwzy](https://www.ruby-forum.com/u/lhmwzy)\
**Post date:** [September 16, 2008, 5:18pm UTC](https://www.ruby-forum.com/t/restrict-access-problem/148724/3 "2008-09-16T17:18:17Z")

</div>

On Tue, Sep 16, 2008 at 10:59:50PM +0800, lhmwzy wrote:

> > when I access [http://10.66.23.102/bxzx/xinxi/](http://10.66.23.102/bxzx/xinxi/) from 10.68.49.210,nginx  
> > location ~ xinxi {  
> > satisfy any;  
> > allow 10.68.49.21;  
> > auth\_basic “need authried”;  
> > auth\_basic\_user\_file passwd;  
> > deny all;  
> > }  
> > can do the job well.

No, the rule order is

```
  any allow/deny
  then auth_basic

```

---

<div class="post-metadata">

**Author:** ![lhmwzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90db22/32.png) [@lhmwzy](https://www.ruby-forum.com/u/lhmwzy)\
**Post date:** [September 16, 2008, 7:55pm UTC](https://www.ruby-forum.com/t/restrict-access-problem/148724/4 "2008-09-16T19:55:33Z")

</div>

2008/9/16 Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > ```
> > > }
> > > 
> > > ```
> 
> No, the rule order is
> 
> ```
> any allow/deny
> then auth_basic
> 
> ```
> 
> –  
> Igor S.  
> [Igor Sysoev](http://sysoev.ru/en/)

OK,let’s do as you say:  
location ~ xinxi {  
allow 10.68.49.21;  
deny all;  
auth\_basic “need authried”;  
auth\_basic\_user\_file passwd;  
}

Also get  
403 Forbidden  
Should get a prompt the enter username and password?  
BTW,I use 0.6.32.

---

<div class="post-metadata">

**Author:** ![lhmwzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90db22/32.png) [@lhmwzy](https://www.ruby-forum.com/u/lhmwzy)\
**Post date:** [September 16, 2008, 9:58pm UTC](https://www.ruby-forum.com/t/restrict-access-problem/148724/5 "2008-09-16T21:58:14Z")

</div>

I think when client ip address isn’t 10.68.49.21,then should prompt  
the enter username and password.if the username and password isn’t  
right,the last should deny access or display not authroised.

---

<div class="post-metadata">

**Author:** ![lhmwzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90db22/32.png) [@lhmwzy](https://www.ruby-forum.com/u/lhmwzy)\
**Post date:** [September 16, 2008, 9:58pm UTC](https://www.ruby-forum.com/t/restrict-access-problem/148724/6 "2008-09-16T21:58:14Z")

</div>

On Tue, Sep 16, 2008 at 11:35:22PM +0800, lhmwzy wrote:

> I think when client ip address isn’t 10.68.49.21,then should prompt  
> the enter username and password.if the username and password isn’t  
> right,the last should deny access or display not authroised.

This is controlled by “satisfy any|all” directive.

---

<div class="post-metadata">

**Author:** ![lhmwzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90db22/32.png) [@lhmwzy](https://www.ruby-forum.com/u/lhmwzy)\
**Post date:** [September 16, 2008, 10:39pm UTC](https://www.ruby-forum.com/t/restrict-access-problem/148724/7 "2008-09-16T22:39:27Z")

</div>

Tks for reply.

2008/9/16 Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![lhmwzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90db22/32.png) [@lhmwzy](https://www.ruby-forum.com/u/lhmwzy)\
**Post date:** [September 16, 2008, 8:34pm UTC](https://www.ruby-forum.com/t/restrict-access-problem/148724/8 "2008-09-16T20:34:29Z")

</div>

On Tue, Sep 16, 2008 at 11:32:29PM +0800, lhmwzy wrote:

> > > > ```
> > > > deny all;
> > > > 
> > > > ```
> > > > 
> > > > Am I right?
> 
> 403 Forbidden  
> Should get a prompt the enter username and password?  
> BTW,I use 0.6.32.

No. You should use “satisfy any” for this.
