Hello!
On Fri, Mar 1, 2013 at 7:58 AM, Ron Gomes wrote:
> ngx.redirect() seems to be usable only with URIs on the same server--at
> least the documentation implies it (the only examples use local URIs).
>
No, it can work with absolute URLs as well:
location = /t {
content_by_lua '
return ngx.redirect("http://www.google.com")
';
}
Accessing /t gives the response:
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.2.7
Date: Fri, 01 Mar 2013 20:37:24 GMT
Content-Type: text/html
Content-Length: 170
Connection: keep-alive
Location: http://www.google.com
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.2.7 (no pool)</center>
</body>
</html>
I've made it explicit in the documentation:
http://wiki.nginx.org/HttpLuaModule#ngx.redirect
> What's the recommended way to redirect to an outside URL?
ngx.redirect() :)
> Do I have to explicitly set the Location response header, and then
> explicitly return a 302 (ngx.HTTP_MOVED_TEMPORARILY)?
Well, you could, but you don't have to :)
Best regards,
-agentzh