# Rewrite rules, for Zope, small problem with authentication user

**URL:** <https://www.ruby-forum.com/t/rewrite-rules-for-zope-small-problem-with-authentication-user/218113>\
**Category:** NGINX\
**Created:** [March 21, 2012, 5:59pm UTC](https://www.ruby-forum.com/t/rewrite-rules-for-zope-small-problem-with-authentication-user/218113 "2012-03-21T17:59:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 21, 2012, 5:59pm UTC](https://www.ruby-forum.com/t/rewrite-rules-for-zope-small-problem-with-authentication-user/218113/1 "2012-03-21T17:59:19Z")

</div>

Hi, List

I would use Nginx with Zope, but with the following configuration I  
can not authenticate the user (from Nginx), otherwise works properly.  
Where am I doing wrong?

…  
upstream database  
{  
postgres\_server 172.16.65.1 dbname=dbname user=username  
password=pwd;  
}

```
upstream zope
{
    server 172.16.65.1:80;
}

server
{
    listen 80;
    server_name www.myhostname.com;
    rewrite ^/(.*)

```

/VirtualHostBase/http/www.myhostname.com/www/VirtualHostRoot/$1 last;  
index index.htm index.html index\_html;

```
    location =/auth
    {
        internal;
        more_set_headers -s 401 'WWW-Authenticate: Basic

```

realm="$auth\_user"’;  
postgres\_escape $user $remote\_user;  
postgres\_escape $pass $remote\_passwd;  
postgres\_pass database;  
postgres\_query “SELECT user FROM usertable WHERE  
user=$user AND pwd=crypt($pass, pwd) $private”;  
postgres\_rewrite no\_rows 401;  
postgres\_output none;  
}

```
    # For registered users in DB
    location /news/
    {
        set $auth_user "News";
        set $private "and reserve ='S'";
        auth_request /auth;
    }

    location /
    {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://zope;
    }

    error_page 405 /error/405.htm;
    error_page 404 /error/404.htm;
    error_page 403 /error/403.htm;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /error/50x.html;
}

```

…

Thanks in advance  
Giuseppe
