off-domain redirect using X-Accel-Redirect
francis at daoine.org
Thu Apr 14 11:41:53 MSD 2011
On Thu, Apr 14, 2011 at 01:36:56AM -0400, dbanks wrote:
> 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;
> 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,
Francis Daly francis at daoine.org
More information about the nginx