view README @ 5:cc231fa95159

Auth request: expand example in README. 1. An example how to don't pass to upstream server body (if happend to be already read from client) and Content-Length header to handle POSTs correctly. 2. An example how to pass original request URI to backend.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 05 Mar 2010 21:20:32 +0300
parents 187ac993cd15
children fb05a061532c
line wrap: on
line source

Auth request module for nginx.

This module allows authorization based on subrequest result.  Once subrequest
returns 2xx status - access is allowed, on 401 or 403 - disabled with
appropriate status.  Anything else is considered to be an error.

For 401 status WWW-Authenticate header from subrequest response will be
passed to client.

Module works at access phase and therefore may be combined nicely with other
access modules (access, auth_basic) via satisfy directive.

Configuration directives:

    auth_request <uri>|off

        Context: http, server, location
        Default: off

        Switches auth request module on and sets uri which will be asked for
        authorization.

Usage:

    location /private/ {
        auth_request /auth;
        ...
    }

    location = /auth {
        proxy_pass ...
        proxy_pass_request_body off;
        proxy_set_header Content-Length "";
        proxy_set_header X-Original-URI $request_uri;
    }

To compile nginx with auth request module, use "--add-module <path>" option
to nginx configure.

Development of this module was sponsored by Openstat (http://www.openstat.com/).