Returning headers from FastCGI

I’m using Nginx (.7.x) as a simple proxy where a couple of FastCGI
applications acts as lookup tables. These apps returns which proxy
backend that should have the request through X-Accel-Redirect - eg /
backend1/$new_uri. Finally I catch these in location matches and pass
the request along with proxy_pass.

Since i scrub the $new_uri somewhat, I want to send additional info
as a header back to Nginx, but I can’t make this work. How do I pass
headers from FastCGI back to Nginx?

Kind Regards,
Johan

On Mon, Aug 18, 2008 at 04:05:01PM +0200, Johan Bergstr?m wrote:

I’m using Nginx (.7.x) as a simple proxy where a couple of FastCGI
applications acts as lookup tables. These apps returns which proxy
backend that should have the request through X-Accel-Redirect - eg /
backend1/$new_uri. Finally I catch these in location matches and pass
the request along with proxy_pass.

Since i scrub the $new_uri somewhat, I want to send additional info
as a header back to Nginx, but I can’t make this work. How do I pass
headers from FastCGI back to Nginx?

You need to preserve your $upstream_http_… header into some variable
in XARed location:

 location /one/ {
     fastcgi_pass ...  # redirect to /two/ via XAR
 }

 location /two/ {
     set  $some_header  $upstream_http_some_header

     proxy_pass  ....
     proxy_set_header   Some-Header   $some_header;

 }