Headers not passed from authorizer PHP script

Just Marc marc at corky.net
Wed Sep 26 15:38:01 MSD 2007


I have the following scenario.   This is what happens under normal 

1. A client request is received and rewritten/forwarded to an authorizer 
PHP script via fastcgi.  The script sets: X-Accel-Redirect, and another 
private session header.

2. nginx sends the file to the client

3. Once nginx is done sending the file, I have a module that reads the 
private session header added by the PHP script and acts accordingly (it 
knows which transfer was made and by whom, by reading the private 
session id header,  it then does some accounting).


Now,  in some cases I found that the module receives an empty session 
header value (in fact, it receives no headers at all set by the PHP 
script) while I verified that the PHP script ran fully in these cases. 
   Nginx wrote a log line about connection as having error code 499.  

In order to operate, my module must receive the session id header that 
was set by the authorizer PHP script and do proper cleanup and accounting.

The way to reproduce this scenario is as follows:

1. Add a sleep of a few seconds to the authorizer PHP script.
2. Issue a request using wget to the URL handled by the script.
3. Once the script is 'stuck' on that sleep, break wget with ctrl-c.

I know the script finishes running fully, the connection gets code 499, 
and the module will not see any headers set by the PHP script for this 

Before writing the module, I also tried a PHP script that's run by 
post_action.    In this case, breaking the wget connection while the 
first (authorizer) PHP script is in 'sleep',  post_action is not 
executed at all.

Any hints would be greatly appreciated!


More information about the nginx mailing list