atom feed11 messages in ru.sysoev.nginxRe: need help calling PHP as a fallback
FromSent OnAttachments
davvvJan 4, 2010 8:46 pm 
Claude BingJan 4, 2010 9:18 pm 
davvvJan 4, 2010 9:36 pm 
Claude BingJan 4, 2010 9:40 pm 
davvvJan 4, 2010 9:46 pm 
Piotr SikoraJan 4, 2010 9:58 pm 
davvvJan 4, 2010 10:25 pm 
Rob SchultzJan 4, 2010 10:31 pm 
Piotr SikoraJan 4, 2010 11:40 pm 
davvvJan 5, 2010 12:14 am 
Edho P AriefJan 5, 2010 1:23 am 
Subject:Re: need help calling PHP as a fallback
From:Claude Bing (tehb@gmail.com)
Date:Jan 4, 2010 9:18:43 pm
List:ru.sysoev.nginx

Is proxy_pass supposed to call something with a .eve extension?

On Jan 4, 2010 11:50 PM, "davvv" <ngin@nginx.us> wrote:

I wrote a very scalable HTTP event server in C++ and I would like to make it work with nginx. My server is on port 9001, PHP-FPM is running on port 9000.

My server is set up to return a 504 error when an event is found, and the 504 error should trigger the PHP backend. I've been trying to figure out a way to make it work with nginx and it's something so elementary, I think I'm just being really stupid.. so I need some help.

This is basically a short rundown of what happens. A client hits something like myhost.com/event/, and hangs until there is an event to server, expiring after 30 seconds by default (if it expires, my server returns a "NO EVENT" reply, which works); however, if there IS an event, my server is set up to kick off the client, triggering a 504. Somehow I want to catch that 504, and redirect the client to a PHP backend (with the query intact).

This is what I have so far. I haven't worked much with nginx so bear with me...

location /event/ { proxy_pass http://localhost:9001/callback.eve; proxy_intercept_errors on; error_page 504 = @fallback; #if I straight up put backend.php here, the POST/GET variables disappear }

location @fallback { internal; fastcgi_param SCRIPT_FILENAME $document_root/backend.php; fastcgi_param QUERY_STRING $query_string; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; }

I get some really strange results with the aforementioned config.. nginx doesn't break, I don't get an error or anything. PHP doesn't break either. All I get is a blank page (as in, totally blank) with a 200 OK code. I'm really confused here, and I'm almost certain there has to be an easy way of doing this

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,36944,36944#msg-36944