# Httpauth bug or my config mistake?

**URL:** <https://www.ruby-forum.com/t/httpauth-bug-or-my-config-mistake/199244>\
**Category:** NGINX\
**Created:** [November 17, 2010, 7:32am UTC](https://www.ruby-forum.com/t/httpauth-bug-or-my-config-mistake/199244 "2010-11-17T07:32:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [November 17, 2010, 7:32am UTC](https://www.ruby-forum.com/t/httpauth-bug-or-my-config-mistake/199244/1 "2010-11-17T07:32:02Z")

</div>

Hi

i try set up http auth in one of my domain sub-folder but httpauth not  
work properly.

mys conf.

```
        location /adm/ {
        auth_basic Restrito;
        auth_basic_user_file /var/www/tv/adm/.htpasswd;
        }

```

Ii type [http://mydomain.com/adm/](http://mydomain.com/adm/) ask for credentials prompt but if type  
[http://mydomain.com/adm/index.php](http://mydomain.com/adm/index.php) not show any credentials prompt and  
protected page are printed.

Thak’s for any help

Posted at Nginx Forum:

> **[httpauth bug or my config mistake?](https://forum.nginx.org/read.php?2,151328,151328#msg-151328)**
>
> Hi i try set up http auth in one of my domain sub-folder but httpauth not work properly. mys conf. location /adm/ { auth\_basic Restrito; auth\_basic\_user\_file /var/www/tv/adm/.htpasswd;

---

<div class="post-metadata">

**Author:** ![maar3amt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@maar3amt](https://www.ruby-forum.com/u/maar3amt)\
**Post date:** [November 17, 2010, 7:38am UTC](https://www.ruby-forum.com/t/httpauth-bug-or-my-config-mistake/199244/2 "2010-11-17T07:38:19Z")

</div>

On Wed, Nov 17, 2010 at 1:30 PM, maar3amt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> auth_basic_user_file /var/www/tv/adm/.htpasswd;
> }
> 
> ```
> 
> Ii type [http://mydomain.com/adm/](http://mydomain.com/adm/) ask for credentials prompt but if type  
> [http://mydomain.com/adm/index.php](http://mydomain.com/adm/index.php) not show any credentials prompt and  
> protected page are printed.
> 
> Thak’s for any help

add

```
        location /adm/.*\.php$ {
        auth_basic Restrito;
        auth_basic_user_file /var/www/tv/adm/.htpasswd;
        <php config goes here>
        }

```

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)

---

<div class="post-metadata">

**Author:** ![maar3amt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@maar3amt](https://www.ruby-forum.com/u/maar3amt)\
**Post date:** [November 17, 2010, 7:55am UTC](https://www.ruby-forum.com/t/httpauth-bug-or-my-config-mistake/199244/3 "2010-11-17T07:55:52Z")

</div>

On 11/17/10 1:37 AM, Edho P Arief wrote:

> > ```
> > auth_basic Restrito;
> > 
> > ```
> 
> add
> 
> ```
> location /adm/.*\.php$ {
> auth_basic Restrito;
> auth_basic_user_file /var/www/tv/adm/.htpasswd;
> <php config goes here>
> }
> 
> ```

An alternative is to do it all in one location:

location ^~ /adm/ {  
auth\_basic Restrito;  
auth\_basic\_user\_file /var/www/tv/adm/.htpasswd;  
location ~ .php$ {  
…  
}  
}

The “^~” forces that location to be checked for before regular  
expressions. See [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpCoreModule#location).

–  
Jim O.

Top posting because that’s where the insertion point is, is like  
shitting in your pants because that’s where your asshole is.

---

<div class="post-metadata">

**Author:** ![maar3amt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@maar3amt](https://www.ruby-forum.com/u/maar3amt)\
**Post date:** [November 17, 2010, 10:51am UTC](https://www.ruby-forum.com/t/httpauth-bug-or-my-config-mistake/199244/4 "2010-11-17T10:51:40Z")

</div>

Thank you ppl.

Posted at Nginx Forum:

> **[Re: httpauth bug or my config mistake?](https://forum.nginx.org/read.php?2,151328,151353#msg-151353)**
>
> Hi i try set up http auth in one of my domain sub-folder but httpauth not work properly. mys conf. location /adm/ { auth\_basic Restrito; auth\_basic\_user\_file /var/www/tv/adm/.htpasswd;
