Returning headers from FastCGI

Igor Sysoev is at
Mon Aug 18 18:32:32 MSD 2008

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;

Igor Sysoev

More information about the nginx mailing list