Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 this url and then instruct it to do several different things, all possible in a location block.

    http://192.158.0.1/web/test.php?hello=test&preview=true&another=var

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?

E.g.

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

Or something aloong those lines?

share|improve this question
    
What are you trying to do? –  Michael Hampton Oct 12 '12 at 13:07
    
To match preview=true in the url in order to disable caching in the location (as location / caches) –  Dave Oct 12 '12 at 20:02

1 Answer 1

up vote 1 down vote accepted

Use the proxy_cache_bypass directive.

proxy_cache_bypass $arg_preview;
share|improve this answer
    
This is correct; thanks Michael. Unfortunately it's not possible to match arguments in a location {} block though –  Dave Oct 13 '12 at 10:27
    
You shouldn't be using a separate location block at all. If this doesn't work with your existing directives, you've probably found a bug in nginx. –  Michael Hampton Oct 13 '12 at 12:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.