Hello!
On Wed, Mar 13, 2013 at 3:46 PM, Peter Booth <peter...@me.com> wrote:
> I was wondering whether the rewrite_by_lua command can be used to get around the limits of nginx's location feature. I understand that locations are based on URI, and don't include parameters. I have one app that uses a single URL to do a range of different things, using both GETs and POSTs.
>
> Ideally, I'd like to define a "location" that only matches a GET for /MyServlet with parameter X on the query string. I'd like to define distinct cookie handling and proxy behavior for this "location" and have different settings for the "real" MyServlet location.
>
This looks like a perfect use case for "internal redirections":
http://openresty.org/download/agentzh-nginx-tutorials-en.html#nginx-variables-variable-lifetime-and-internal-redirection
You can also initiate internal redirections to your internal locations
from with rewrite_by_lua via ngx.req.set_uri(uri, true) or ngx.exec().
To make a internal location, just put a "internal;" line in that
location block or define a "named location" like this:
location @foo {
...
}
Your main public location can serve as a dispatcher and the fallback
for the most common case.
Best regards,
-agentzh