I have nginx running at port 80 and a php hiphop server running at 4247.
I want to achieve the following configuration -
Whenever a request is received at nginx port 80, it should be sent to
some auth_url (say auth.php) and if it is authorized then it should be
forwarded/proxied to hiphop server running at 4247. If not some error
page should be thrown.
I was looking through ngx_http_auth_request_module and other inbuilt
modules. But I have the following doubts -
What could the possible config look like where both
ngx_http_auth_request_module and proxy_pass are included?
For my auth.php, what should it return true/false or something else?
In this as I understand it redirects to error_page on receiving a 4xx
status code. Is it possible that nginx reads the value of error page
from a custom header which comes along with the response (with 4xx
status code) and then assign the value of error_page to that value.
On Fri, Feb 17, 2012 at 03:57:50AM -0500, karanj wrote:
One additional question here -
In this as I understand it redirects to error_page on receiving a 4xx
status code. Is it possible that nginx reads the value of error page
from a custom header which comes along with the response (with 4xx
status code) and then assign the value of error_page to that value.
You may use use auth_request_set to make headers available as
variables in main request.
2012/02/17 18:52:45 [error] 10103#0: *4 the rewritten URI has a zero
length, client: 122.179.93.88, server: 112.11.23.221, request: “GET
/tf2/test2.php HTTP/1.1”, host: “112.11.23.221:8080”
Note that the auth_request module only uses the headers. So your
auth.php authorization script must take that into account.
Does it enter this section after it gets 2xx response from auth.php?
When the /auth.php location returns 200 then the request is authorized and the request is proxy passed to the hiphop upstream in
the index.php location from the above example.