# Forcing a Basic Dialog Box

**URL:** <https://www.ruby-forum.com/t/forcing-a-basic-dialog-box/215316>\
**Category:** NGINX\
**Created:** [December 30, 2011, 4:15am UTC](https://www.ruby-forum.com/t/forcing-a-basic-dialog-box/215316 "2011-12-30T04:15:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [December 30, 2011, 4:15am UTC](https://www.ruby-forum.com/t/forcing-a-basic-dialog-box/215316/1 "2011-12-30T04:15:48Z")

</div>

I am trying to use the new postgres module and cant figure out how to  
force a “Basic” dialog on the browser to do auth.

I am running v 1.0.11

The auth is working correctly ie: [http://user:removed\_email\_address@domain.invalid](http://user:removed_email_address@domain.invalid) correctly  
authenticates.

The thing I want to happen is force the Basic dialog in the browser to  
pass the credentials.

Here is my config.

Thanks.

location / {  
auth\_basic “Restricted”;  
root /var/www/web/;  
auth\_request /auth;

```
     try_files $uri $uri/ @upstream;
 }

```

location /auth {  
internal;

```
         postgres_escape $user $remote_user;
         postgres_escape $pass $remote_passwd;

         postgres_pass database;
         postgres_query "SELECT login FROM users WHERE

```

login=$user AND pass=$pass";  
postgres\_rewrite no\_rows 403;  
postgres\_output none;  
}

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [December 30, 2011, 12:51pm UTC](https://www.ruby-forum.com/t/forcing-a-basic-dialog-box/215316/2 "2011-12-30T12:51:50Z")

</div>

Hello!

On Thu, Dec 29, 2011 at 10:14:58PM -0500, David wrote:

> Here is my config.
> 
> Thanks.
> 
> location / {  
> auth\_basic “Restricted”;

Just a side note: this line is useless.

> ```
> root /var/www/web/;
> auth_request /auth;
> 
> ```

Browser will show auth dialog as long as it gets 403 with  
WWW-Authenticate header. With auth\_request it’s auth script  
responsibility to provide this header.

> ```
> postgres_pass database;
> postgres_query "SELECT login FROM users WHERE
> 
> ```
> 
> login=$user AND pass=$pass";  
> postgres\_rewrite no\_rows 403;  
> postgres\_output none;  
> }

No idea if postgres module is able to set one.

Maxim D.

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [December 30, 2011, 1:01pm UTC](https://www.ruby-forum.com/t/forcing-a-basic-dialog-box/215316/3 "2011-12-30T13:01:44Z")

</div>

Hi,

On Thu, Dec 29, 2011 at 10:14:58PM -0500, David wrote:

> Here is my config.

it looks like your configuration file little bit different than  
“Sample configuration #4” from ngx\_postgres-0.9/README.md

> location / {  
> auth\_basic “Restricted”;  
> root /var/www/web/;  
> auth\_request /auth;
> 
> ```
> try_files $uri $uri/ @upstream;
> }
> 
> ```

-location /auth {  
+location = /auth {

> ```
> }
> 
> ```

Also, “location /” below that “location = /auth”.  
Could you please try original example.

–  
Sergey A. Osokin  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [January 2, 2012, 10:47am UTC](https://www.ruby-forum.com/t/forcing-a-basic-dialog-box/215316/4 "2012-01-02T10:47:41Z")

</div>

Fantastic.

That worked great. I didnt realize I needed the extra $more\_headers  
package.

Appreciate your help.

Thank you!

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [January 2, 2012, 5:14am UTC](https://www.ruby-forum.com/t/forcing-a-basic-dialog-box/215316/5 "2012-01-02T05:14:22Z")

</div>

Hi,  
diff inline.

Please note that you’ll also need ngx\_headers\_more module:

> **[GitHub - openresty/headers-more-nginx-module: Set, add, and clear arbitrary output headers in...](https://github.com/openresty/headers-more-nginx-module)**
>
> Set, add, and clear arbitrary output headers in NGINX http servers

> location / {  
> auth\_basic “Restricted”;

-auth\_basic “Restricted”;

> ```
> root /var/www/web/;
> auth_request /auth;
> 
> try_files $uri $uri/ @upstream;
> }
> 
> ```
> 
> location /auth {

-location /auth {  
+location = /auth {

> ```
> internal;
> 
> postgres_escape $user $remote_user;
> postgres_escape $pass $remote_passwd;
> 
> postgres_pass database;
> postgres_query "SELECT login FROM users WHERE
> 
> ```
> 
> login=$user AND pass=$pass";  
> postgres\_rewrite no\_rows 403;

-postgres\_rewrite no\_rows 403;  
+postgres\_rewrite no\_rows 401;  
+more\_set\_headers -s 401 ‘WWW-Authenticate: Basic realm=“Restricted”’;

> ```
> postgres_output none;
> }
> 
> ```

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>
