I have setup wordpress proxy for all routes but I don't want to proxy the preview urls. The typical url looks like this. I would rather setup the proxy rule so if it contains preview=true don't proxy it.


This is what I have so far

location ~.*preview_id.* {
    try_files $uri $uri/ /index.php?q=$uri&$args;
| improve this question | | | | |
  • What is the preview? Is it at /slug/index.html? Also, you cannot use location to test preview_id as it's part of the query string. You could use if ($arg_preview_id) { ... } instead. – Richard Smith Dec 3 '18 at 10:08

preview is a GET-argument, not a part of the URI from the nginx point of view (although it may appear to you as one), so you need to check $arg_ variables, not the location.

| improve this answer | | | | |
  • Can you please provide a more detailed answer. I can't add if statement and check inside the location because I either get can't proxy inside if statement or try_files" directive is not allowed here in based on the way I write my if statement. – Yasin Yaqoobi Dec 3 '18 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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