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: