Maxim Dounin
April 22, 2010 04:52PM
Hello!

On Thu, Apr 22, 2010 at 09:56:29AM -0400, riobard wrote:

> I'm having some trouble with FastCGI backend sending custom
> headers to client while using X-Accel-Redirect. My backend PHP
> does something like this:
>
>
> header( "custom-header: some-value" );
> header( "X-Accel-Redirect: " . $cache_file);
>
>
> If I don't use X-Accel-Redirect everything is fine (i.e. I can
> see the custom-header from client side). But Nginx seems to
> strip all headers set by my PHP backend if X-Accel-Redirect is
> used. Any idea why and how I can add it back? Thanks very much!

nginx preserves only some specific headers (Set-Cookie and so on)
on X-Accel-Redirect. For anything else you may to do something
like this:


location / {
fastcgi_pass ...

# here are headers returned:
# X-Accel-Redirect: /redirected/...
# X-Custom: something
}

location /redirected/ {
internal;
add_header X-Custom $upstream_x_custom;
...
}

Note that if "/redirected/" does proxy_pass/fastcgi_pass in it's
turn you have to store $upstream_x_custom into some intermediate
value via "set" directive (or it will be cleared/overriden by next
upstream request).

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Pass headers from FastCGI backend to client while X-Accel-Redirect

riobard April 22, 2010 09:56AM

Re: Pass headers from FastCGI backend to client while X-Accel-Redirect

Maxim Dounin April 22, 2010 04:52PM

Re: Pass headers from FastCGI backend to client while X-Accel-Redirect

riobard April 22, 2010 08:29PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 227
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready