Pre-process request via upstream then forward to proxy.

Maxim Dounin mdounin at mdounin.ru
Thu May 5 10:31:10 MSD 2011


Hello!

On Thu, May 05, 2011 at 12:11:30AM -0400, AndrewH wrote:

> As part of processing a request, I need to first send and receive a
> response to/from an upstream to authenticate some credentials in the
> request.  Once this has been done, the original request needs to be
> proxied to another upstream.
> 
> According to Evan Miller's tutorial, the only valid location for
> spawning sub-requests is in an output filter ie. to post-process a
> response.  So it appears that this approach is useful for massaging a
> reponse but not valid for actually performing pre-processing on a
> request.

Evan Miller's claim was correct before 0.7.25.  In recent versions 
you may issue subrequests almost everywhere.  There are some 
caveats though - it's up to you to take appropriate measures to 
ensure subrequest response won't appear on client's connection.

> Does anyone know what the sanctioned way of going about this in NGINX
> is?  Or which existing modules/examples implement similar
> functionality?

Take a look at:

http://grid.net.ru/nginx/eval.en.html
http://mdounin.ru/hg/ngx_http_auth_request_module/

Maxim Dounin



More information about the nginx mailing list