Jeff Waugh
September 30, 2009 05:06AM
<quote who="pepejose">

> -- In the first case X-Accel-Redirect not working because the image is in
> memory? -- If I change the second case to:
>
> header("Content-type: image/jpeg"); header("X-Accel-Redirect: /$image");
> readfile($image);
>
> how can I know if the header X-Accel-Redirect is working?

The X-Accel-Redirect header basically says:

Dear nginx (or some other frontend),

I know you're talking to me with fastcgi or http (proxy), but now I've
figured out that I'm just going to be sending the client a file. You can
do this better than me (by talking directly to the kernel and disk, and
not sending the file over the fastcgi or proxy connection), so here's the
name of the file.

Love,

Backend Application


So, what you want to do in your backend is this:

header("Content-type: image/jpeg");
if ( X_ACCEL_DIRECT ) { // this shoudl configurable in a productised app
header("X-Accel-Redirect: /$image");
exit;
}
readfile($image); // send the image if we're not using X-Accel-Redirect


The initial path should probably be mildly more unique though, so you can
deal with it separately in your nginx configuration. But not necessarily.

Short answer: X-Accel-Redirect is helpful only when the file is on disk.

:-)

- Jeff

--
linux.conf.au 2010: Wellington, NZ http://www.lca2010.org.nz/

"First-born children are less creative but more stable, while last-born
are more promiscuous, says US research." - BBC News, 2005
Subject Author Posted

X-Accel-Redirect

pepejose September 30, 2009 03:44AM

Re: X-Accel-Redirect

Gabriel Ramuglia September 30, 2009 04:44AM

Re: X-Accel-Redirect

Jeff Waugh September 30, 2009 05:06AM

Re: X-Accel-Redirect

pepejose September 30, 2009 05:12AM

Re: X-Accel-Redirect

Jeff Waugh September 30, 2009 05:48AM

Re: X-Accel-Redirect

Maxim Dounin September 30, 2009 06:12AM

Re: X-Accel-Redirect

Kiril Angov September 30, 2009 08:08AM

Re: X-Accel-Redirect

Jeff Waugh September 30, 2009 08:44AM

Re: X-Accel-Redirect

Gabriel Ramuglia September 30, 2009 01:30PM

Re: X-Accel-Redirect

pepejose September 30, 2009 10:50AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 287
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