Off-domain redirect using X-Accel-Redirect

Hello,

I’d like for my application to send a 302 redirect (or equivalent) to an
off-domain location (not my server). X-Accel-Redirect appears to be the
best way to achieve this, but I don’t see any reference to the URI being
a reference to a different server.

Is something like the following allowed?

X-Accel-Redirect: http://www.google.com;
or
X-Accel-Redirect: http://img.pics.com/mypic.gif;

I get a 404 from nginx when attempting this. I do not have any
X-specific header directives (block or pass) in my configuration.

To be clear, I don’t mind debugging it myself, I just want to verify
that this is possible before I spend too much time on it.

Cheers,

Dean

Posted at Nginx Forum:

On Thu, Apr 14, 2011 at 01:36:56AM -0400, dbanks wrote:

Hi there,

I’d like for my application to send a 302 redirect (or equivalent) to an
off-domain location (not my server). X-Accel-Redirect appears to be the
best way to achieve this, but I don’t see any reference to the URI being
a reference to a different server.

X-Accel-Redirect is for the application to tell nginx to return the
content of a different (local) uri. The value should start with “/”.

Nginx is a proxy server, so there are ways to map a local uri to a
remote
resource, but that seems to be a side issue here:

if you want your application to send a 302 redirect, just send a 302
redirect. You’ll need a valid Location: header too.

Is something like the following allowed?

X-Accel-Redirect: http://www.google.com;
or
X-Accel-Redirect: http://img.pics.com/mypic.gif;

It’s allowed, but it doesn’t do what you hope it does.

If you look in the debug log, you’ll see something like

open() “/usr/local/nginx/htmlhttp://www.google.com;” failed (2: No such
file or directory)

Good luck with it,

f

Francis D. [email protected]

Sending a 302 directly works great. Thanks!

Posted at Nginx Forum:

it would be nice to support this. it’s basically dynamic/reproxy
capabilities, which is what is in perlbal, which is needed for
mogilefs support. I thought nginx had something like this internally,
or perhaps Valery figured out a neat way in his mogilefs module.