Rewrite rules, for Zope, small problem with authentication user

Giuseppe Tofoni gt0057 at gmail.com
Wed Mar 21 16:57:12 UTC 2012


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



More information about the nginx mailing list