Nginx location to match query parameters

Dave asked:

Is it possible in nginx to have a location {...} block that matches query parameters. For example I want to pick up that preview=true in URL below and then instruct it to do several different things, all possible in a location block.

The problem I’m having is that my test stuff doesn’t seem to match, it seems like I can only match the URL itself?


location ~ ^(.*)(preview)(.*)$

Or something aloong those lines?

My answer:

Use the proxy_cache_bypass directive.

proxy_cache_bypass $arg_preview;

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.