Passing extra headers along with a X-Accel-Redirect

Hi,

I have a backend in PHP that is using X-Accel-Redirect to make nginx
send a file. Along with that file, I have to set up some headers, with
content that will be decided by the PHP backend. If I just add a
header in PHP, nginx eats it. Is there anyway to pass an extra header
from PHP to the end client?

Thanks!

Joaquin Cuenca Abela wrote:

Hi,

I have a backend in PHP that is using X-Accel-Redirect to make nginx
send a file. Along with that file, I have to set up some headers, with
content that will be decided by the PHP backend. If I just add a
header in PHP, nginx eats it. Is there anyway to pass an extra header
from PHP to the end client?

Thanks!

Hi,
AFAIK, nginx does not eat up the headers.
Most probably your headers from php are being overridden by the
headers send by the proxied server.

You many use proxy_hide_header directive to suppress headers from
the proxied server. This will prevent the headers from your php.

  • Anup

Joaquin Cuenca Abela wrote:

Hi,

I have a backend in PHP that is using X-Accel-Redirect to make nginx
send a file. Along with that file, I have to set up some headers, with
content that will be decided by the PHP backend. If I just add a
header in PHP, nginx eats it. Is there anyway to pass an extra header
from PHP to the end client?

Thanks!

Hi,
AFAIK, nginx does not eat up the headers.
Most probably your headers from php are being overridden by the
headers sent by the proxied server.

You many use proxy_hide_header directive to suppress headers from
the proxied server. This will preserve the headers from your php.

  • Anup

:: Just to fix some stupid spelling mistakes.

Hello!

On Fri, Apr 04, 2008 at 02:16:29PM +0200, Joaquin Cuenca Abela wrote:

Hi,

I have a backend in PHP that is using X-Accel-Redirect to make nginx
send a file. Along with that file, I have to set up some headers, with
content that will be decided by the PHP backend. If I just add a
header in PHP, nginx eats it. Is there anyway to pass an extra header
from PHP to the end client?

With X-Accel-Redirect only several hardcoded headers are passed to
client from original response (i.e. one which returned
X-Accel-Redirect). Full list (see ngx_http_upstream.c):

“Content-Type”, “Set-Cookie”, “Content-Disposition”,
“Cache-Control”, “Expires”, “Accept-Ranges”

The only way to change this list now is to patch sources.

Maxim D.

Hi,

On Sat, Apr 5, 2008 at 1:52 PM, Maxim D. [email protected] wrote:

from PHP to the end client?

With X-Accel-Redirect only several hardcoded headers are passed to client from original response (i.e. one which returned X-Accel-Redirect). Full list (see ngx_http_upstream.c):
“Content-Type”, “Set-Cookie”, “Content-Disposition”, “Cache-Control”, “Expires”, “Accept-Ranges”

The only way to change this list now is to patch sources.

Fair enough. Any idea for the rationale of this? I think it makes more
sense to just blindly copy all the headers from the original response.

Cheers,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs