rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* Rack::Sendfile and Rack::Auth tiny example
@ 2012-09-26 13:32 Black
  0 siblings, 0 replies; only message in thread
From: Black @ 2012-09-26 13:32 UTC (permalink / raw)
  To: rack-devel

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

Hi all,


I'm new to rack, I use nginx as reverse proxy for many services, I want to 
setup a global authentification on my site based on MySQL.
I think at this schema:
Nginx pass the request to my auth (a Rack service :8008)
:8008 use its Auth module to authentificate the user, then it use Sendfile 
to tell to Nginx which page to serve
Nginx take the request and route to the good service.

I haven't found any documentation on my problem (especially on the Sendfile 
part).

I try this :

  location / {
    proxy_pass         http://127.0.0.1:8008/;
    proxy_redirect     off;

    proxy_set_header   Host                $host;
    proxy_set_header   X-Real-IP           $remote_addr;
    proxy_set_header   X-Forwarded-For     $proxy_add_x_forwarded_for;

    proxy_set_header   X-Sendfile-Type     X-Accel-Redirect;

  }

And :
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')

use Rack::ShowExceptions


use Rack::Auth::Basic, "Authentification" do |username, password|
    next username == password

end

use Rack::Sendfile
run lambda { |env| [200, {}, []] }

But it fails, have you got a tiny example which should work?

For your help,
In advance,
Thanks.

[-- Attachment #2: Type: text/html, Size: 1696 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-09-26 19:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-26 13:32 Rack::Sendfile and Rack::Auth tiny example Black

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).